lyimo commited on
Commit
b6855e2
·
verified ·
1 Parent(s): 48c7e68

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+ from fastai.vision.all import PILImage
5
+
6
+ learn = load_learner('export.pkl')
7
+
8
+ labels = learn.dls.vocab
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ img = img.resize((512, 512))
13
+ pred,pred_idx,probs = learn.predict(img)
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+ examples = ['image.jpg']
17
+
18
+ #gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
19
+ gr.Interface(fn=predict,inputs=gr.components.Image(),outputs=gr.components.Label(num_top_classes=3),examples=examples,).launch()