Lorenzo Pattori
commited on
Commit
•
e00bdf0
1
Parent(s):
1428031
Added Models & image recognition
Browse files
app.py
CHANGED
@@ -1,12 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello, " + name + "!" * int(intensity)
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
from fastai.learner import load_learner
|
4 |
+
from fastai.vision.all import *
|
5 |
|
6 |
+
learn = load_learner(hf_hub_download("lpattori/Vinchucas","model.pkl"))
|
|
|
7 |
|
8 |
+
labels = learn.dls.vocab
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
pred,pred_idx,probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
|
14 |
+
title = "Kissing Bug Recognizer"
|
15 |
+
description = "Kissing Bug Recognizer trained on the CEPAVE dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
16 |
+
article = ""
|
17 |
+
examples = [img for img in Path("examples").rglob("*")]
|
18 |
+
|
19 |
+
inputs = gr.Image(height=512, width=512)
|
20 |
+
outputs = gr.Label(num_top_classes=3)
|
21 |
+
demo = gr.Interface(fn=predict,inputs=inputs,
|
22 |
+
outputs=outputs,title=title,
|
23 |
+
description=description,article=article,examples=examples)
|
24 |
demo.launch()
|