646e62 commited on
Commit
4c85cfb
·
1 Parent(s): d3334ec

Update app.py

Browse files

fastai Gradio + HuggingFace demo

Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -5,3 +5,13 @@ def greet(name):
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
8
+
9
+ learn = load_learner('export.pkl')
10
+
11
+ labels = learn.dls.vocab
12
+ def predict(img):
13
+ img = PILImage.create(img)
14
+ pred,pred_idx,probs = learn.predict(img)
15
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
16
+
17
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)