Spaces:
Running
Running
| """ | |
| Space Gradio — Classification de feuilles de haricot (ViT). | |
| Auteur: Kanyep darry (kanyep) | |
| TP MLOps - Hugging Face | |
| """ | |
| import gradio as gr | |
| from transformers import pipeline | |
| MODEL_ID = "kanyep/vit-beans-demo" | |
| print(f"Chargement du pipeline image-classification avec {MODEL_ID}...") | |
| 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 de haricot"), | |
| outputs=gr.Label(num_top_classes=3, label="Diagnostic prédit"), | |
| title="🌱 Bean Leaf Disease Classifier (ViT)", | |
| description=( | |
| "### TP MLOps — Modèle Vision Transformer (ViT) fine-tuné\\n" | |
| f"**Modèle Hub :** [{MODEL_ID}](https://huggingface.co/{MODEL_ID})\\n" | |
| "**Auteur :** Kanyep darry (`kanyep`)\\n\\n" | |
| "Déposez une image d'une feuille de haricot pour diagnostiquer son état de santé : " | |
| "saine (`healthy`) ou atteinte de maladie (`angular_leaf_spot` ou `bean_rust`)." | |
| ), | |
| examples=None, | |
| theme=gr.themes.Soft(), | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |