Spaces:
Runtime error
Runtime error
parkermoe commited on
Commit ·
8cf2d92
1
Parent(s): 9028f11
'move dir'
Browse files
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
#|export
|
| 5 |
+
learn = load_learner('model.pkl')
|
| 6 |
|
| 7 |
+
#|export
|
| 8 |
+
categories = learn.dls.vocab
|
| 9 |
+
|
| 10 |
+
def classify_image(inp):
|
| 11 |
+
pred,pred_idx,probs = learn.predict(inp)
|
| 12 |
+
return dict(zip(categories, map(float, probs)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image(shape=(128,128))
|
| 15 |
+
label = gr.outputs.Label(num_top_classes=3)
|
| 16 |
+
examples = ['teddy_1.jpg', 'grizzly_1.jpg','black_bear.jpg']
|
| 17 |
+
|
| 18 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Bear Classifier', description='An AI that identifies bears')
|
| 19 |
+
intf.launch()
|