Spaces:
Runtime error
Runtime error
add app.py and requirements.txt
Browse files- app.py +18 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
learn = load_learner('mode.pkl')
|
| 5 |
+
|
| 6 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 7 |
+
label = gr.outputs.Label()
|
| 8 |
+
examples = ['grizzly.jpg', 'black-bear.jpg', 'teddy-bear.jpg']
|
| 9 |
+
|
| 10 |
+
categories = ('Grizzly Bear', 'Black Bear', 'Teddy Bear')
|
| 11 |
+
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred, idx, probs = learn.predict(img)
|
| 14 |
+
return dict(zip(categories, map(float, probs)))
|
| 15 |
+
|
| 16 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 17 |
+
intf.launch(inline=False)
|
| 18 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
fastai
|