jalarrimore commited on
Commit
793c2f6
·
1 Parent(s): 8c99323

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+
6
+ learn = load_learner('export.pkl')
7
+
8
+ categories = ('black', 'grizzly', 'teddy')
9
+ def classify_image(img):
10
+ pred, idx, probs = learn.predict(img)
11
+ return dict(zip(categories, map(float, probs)))
12
+
13
+ image=gr.inputs.Image(shape=(192, 192))
14
+ label = gr.outputs.Label()
15
+ examples = ['Ronan_Grizzly_Bear_1.jpg','blackbear.jpg',
16
+ 'blackbear2.jpg','brownbear.jpg',
17
+ 'polar.jpg']
18
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
19
+ intf.launch(inline=False)