Spaces:
Runtime error
Runtime error
Walterchamy
commited on
Commit
•
4633b6d
1
Parent(s):
9667a44
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
learn = load_learner('model.pkl')
|
2 |
+
|
3 |
+
labels = learn.dls.vocab
|
4 |
+
def predict(img):
|
5 |
+
img = PILImage.create(img)
|
6 |
+
pred,pred_idx,probs = learn.predict(img)
|
7 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
8 |
+
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=6)).launch(share=True)
|