Spaces:
Runtime error
Runtime error
Sameer Segal commited on
Commit ·
aff8606
1
Parent(s): e50fd25
Created based on fastai tutorial
Browse files- .gitattributes +2 -0
- .gitignore +2 -0
- app.py +22 -0
- model.pkl +3 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
|
@@ -32,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.png
|
| 2 |
+
*.jpg
|
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 5 |
+
learn = load_learner('model.pkl')
|
| 6 |
+
labels = learn.dls.vocab
|
| 7 |
+
|
| 8 |
+
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 11 |
+
return {labels[i] : float(probs[i]) for i in range(len(labels))}
|
| 12 |
+
|
| 13 |
+
# Create the gradio interface with title, description, default interpretation, and examples (car.jpg and scooter.png) that shows only the top 1 prediction
|
| 14 |
+
|
| 15 |
+
gr.Interface(fn=predict,
|
| 16 |
+
title="Car or Scooter",
|
| 17 |
+
description="Upload an image of a car or scooter and we'll tell you which one it is.",
|
| 18 |
+
inputs=gr.inputs.Image(shape=(192, 192)),
|
| 19 |
+
outputs=gr.outputs.Label(num_top_classes=1),
|
| 20 |
+
interpretation="default",
|
| 21 |
+
examples=[["car.jpg"], ["scooter.png"]]
|
| 22 |
+
).launch()
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:092c988452ea874f98140ca906003abc6585755f313a106c8f7ce3d5864287fc
|
| 3 |
+
size 46955567
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|
| 3 |
+
|