ezzats commited on
Commit
1a2ec6c
·
verified ·
1 Parent(s): 591a821

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Space Gradio — Classificateur de feuilles de haricot (ViT fine-tuné).
3
+ """
4
+ import gradio as gr
5
+ from transformers import pipeline
6
+
7
+ MODEL_ID = "nateraw/vit-base-beans"
8
+ classifier = pipeline("image-classification", model=MODEL_ID)
9
+
10
+ def predict(image):
11
+ if image is None:
12
+ return {}
13
+ preds = classifier(image)
14
+ return {p["label"]: float(p["score"]) for p in preds}
15
+
16
+ demo = gr.Interface(
17
+ fn=predict,
18
+ inputs=gr.Image(type="pil", label="Image de feuille"),
19
+ outputs=gr.Label(num_top_classes=3, label="Prédiction"),
20
+ title="🌱 Bean Leaf Classifier (ViT)"
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ demo.launch()