IsmaiL09 commited on
Commit
254d9ad
·
1 Parent(s): 30e5f6d
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import*
2
+ import gradio as gr
3
+
4
+ __all__= ['learn', 'labels', 'predict', 'image', 'label', 'examples', 'iface']
5
+
6
+ learn = load_learner('export.pkl')
7
+
8
+ labels = learn.dls.vocab
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred,pred_idx,probs = learn.predict(img)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+ image = gr.inputs.Image(shape=(192, 192))
16
+ label = gr.outputs.Label()
17
+ examples = ['black-bear.jpg', 'grizzly.jpg', 'teddy-bear.png']
18
+
19
+
20
+ iface = gr.Interface(fn=predict, inputs=image, outputs=label, examples=examples)
21
+ iface.launch(inline=False)