Spaces:
Runtime error
Runtime error
Elam
commited on
Commit
·
533d210
1
Parent(s):
a7b3b82
final app.py file
Browse files- app.py +14 -4
- model.pkl +3 -0
- motorbike.jpg +0 -0
- volkswagen.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn = load_learner('model.pkl')
|
|
|
|
| 5 |
|
| 6 |
+
|
| 7 |
+
categories = ('Car', 'Bike')
|
| 8 |
+
def classify_image(img):
|
| 9 |
+
is_car,_,probs = learn.predict(PILImage.create(img))
|
| 10 |
+
return dict(zip(categories, map(float,probs))) #gradio only supports floats and it doesn't handle PyTorch tensors
|
| 11 |
+
|
| 12 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 13 |
+
label = gr.outputs.Label()
|
| 14 |
+
examples = ['volkswagen.jpg','motorbike.jpg']
|
| 15 |
+
|
| 16 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 17 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0362548f7d683cb903cdd048e4084539cb1dfd57a91e1d81eee63b315fb8135d
|
| 3 |
+
size 46954713
|
motorbike.jpg
ADDED
|
volkswagen.jpg
ADDED
|