Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as pr
|
| 2 |
+
from huggingface_hub import from_pretrained_fastai
|
| 3 |
+
|
| 4 |
+
hf_learn = from_pretrained_fastai("CarlosChcn/Pieridae_Classifier")
|
| 5 |
+
|
| 6 |
+
learn = hf_learn
|
| 7 |
+
labels = learn.dls.vocab
|
| 8 |
+
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
+
|
| 13 |
+
gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=5)).launch(share=True)
|