Spaces:
Sleeping
Sleeping
Commit ·
a000f01
1
Parent(s): 462a2cf
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
-
|
| 6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
| 1 |
+
learn = load_learner('export.pkl')
|
| 2 |
+
labels = learn.dls.vocab
|
| 3 |
+
def predict(img):
|
| 4 |
+
img = PILImage.create(img)
|
| 5 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 6 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 7 |
import gradio as gr
|
| 8 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|