Spaces:
Running
Running
File size: 1,244 Bytes
67a5818 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """
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()
|