Update app.py
Browse filesfastai Gradio + HuggingFace demo
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)
|