Download app.py from HamzaAS/bean-leaf-classifier-space: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/spaces/HamzaAS/bean-leaf-classifier-space/resolve/main/app.py
- Command line
-
hf download hf://spaces/HamzaAS/bean-leaf-classifier-space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/HamzaAS/bean-leaf-classifier-space/resolve/main/app.py
658 Bytes
| """ | |
| Space Gradio — Classificateur de feuilles de haricot (ViT fine-tuné). | |
| """ | |
| import gradio as gr | |
| from transformers import pipeline | |
| MODEL_ID = "nateraw/vit-base-beans" | |
| classifier = pipeline("image-classification", model=MODEL_ID) | |
| def predict(image): | |
| if image is None: | |
| return {} | |
| preds = classifier(image) | |
| return {p["label"]: float(p["score"]) for p in preds} | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil", label="Image de feuille"), | |
| outputs=gr.Label(num_top_classes=3, label="Prédiction"), | |
| title="🌱 Bean Leaf Classifier (ViT)" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |