Spaces:
Runtime error
Runtime error
parkermoe
commited on
Commit
·
9028f11
1
Parent(s):
d78bff6
'adding app file'
Browse files- bear_class.py/app.py +19 -0
bear_class.py/app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|