Spaces:
Runtime error
Runtime error
Abhi
commited on
Commit
·
eb08946
1
Parent(s):
d66811e
app added
Browse files- app.py +16 -4
- teddy_bear.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learner = load_learner('model.pkl')
|
| 5 |
+
|
| 6 |
+
im = PILImage.create('teddy_bear.jpg')
|
| 7 |
+
print(learner.predict(im))
|
| 8 |
+
|
| 9 |
+
categories = ['grizzly', 'black', 'teddy']
|
| 10 |
+
def classify_img(img):
|
| 11 |
+
pred, idx, probs = learner.predict(img)
|
| 12 |
+
return dict(zip(categories,map(float,probs)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image(shape=512,512)
|
| 15 |
+
label = gr.outputs.Label()
|
| 16 |
+
examples = ['teddy_bear.jpg']
|
| 17 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label,examples=examples)
|
| 18 |
+
iface.launch(inline=False)
|
| 19 |
|
|
|
|
|
|
teddy_bear.jpg
ADDED
|