Spaces:
Sleeping
Sleeping
Commit ·
48d944c
1
Parent(s): 84e47af
Update
Browse files- app.py +10 -3
- examples/cat.jpg +0 -0
- examples/dog.jpg +0 -0
- examples/fish.jpg +0 -0
app.py
CHANGED
|
@@ -3,9 +3,16 @@ from fastai.vision.all import *
|
|
| 3 |
|
| 4 |
learn = load_learner('pets.pkl')
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def categorize(image):
|
| 7 |
pred,_,probs = learn.predict(image)
|
| 8 |
-
return
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
iface = gr.Interface(fn=categorize, inputs=
|
| 11 |
-
iface.launch()
|
|
|
|
| 3 |
|
| 4 |
learn = load_learner('pets.pkl')
|
| 5 |
|
| 6 |
+
categories = ("Cat", "Dog", "Fish")
|
| 7 |
+
|
| 8 |
+
examples = ['examples/cat.jpg', 'examples/dog.jpg', 'examples/fish.jpg']
|
| 9 |
+
|
| 10 |
def categorize(image):
|
| 11 |
pred,_,probs = learn.predict(image)
|
| 12 |
+
return dict(zip(categories, map(float, probs)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 15 |
+
label = gr.outputs.Label()
|
| 16 |
|
| 17 |
+
iface = gr.Interface(fn=categorize, inputs=image, outputs=label, examples=examples)
|
| 18 |
+
iface.launch(inline=False)
|
examples/cat.jpg
ADDED
|
examples/dog.jpg
ADDED
|
examples/fish.jpg
ADDED
|