Asteriks commited on
Commit
b9c5885
·
1 Parent(s): d2da15c

Create new file

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