Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained_fastai
|
3 |
+
|
4 |
+
examples = ["image_1.png", "image_2.png"]
|
5 |
+
repo_id = "hugginglearners/grapevine_leaves_classification"
|
6 |
+
|
7 |
+
learner = from_pretrained_fastai(repo_id)
|
8 |
+
|
9 |
+
def inference(image):
|
10 |
+
label_predict,_,probs = learner.predict(img)
|
11 |
+
return f"This grapevine leave is {label_predict} with {100*probs[torch.argmax(probs)].item():.2f}% probability"
|
12 |
+
|
13 |
+
gr.Interface(
|
14 |
+
fn=inference,
|
15 |
+
title="Grapevine leave image classification",
|
16 |
+
description = "Predict which type of grapevine leave belong to Ak, Ala_Idris, Buzgulu, Dimnit, Nazli",
|
17 |
+
inputs="image",
|
18 |
+
examples=examples,
|
19 |
+
outputs=gr.Textbox(label='Prediction'),
|
20 |
+
cache_examples=False,
|
21 |
+
article = "Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>",
|
22 |
+
).launch(debug=True, enable_queue=True)
|