""" Space Gradio — Analyse de sentiment (DistilBERT fine-tuné). """ import gradio as gr from transformers import pipeline MODEL_ID = "HamzaAS/distilbert-sentiment-demo" classifier = pipeline("sentiment-analysis", model=MODEL_ID, truncation=True) def predict(text): if not text or not text.strip(): return {} preds = classifier(text, top_k=None) return {p["label"]: float(p["score"]) for p in preds} demo = gr.Interface( fn=predict, inputs=gr.Textbox(lines=4, label="Votre texte", placeholder="This movie was fantastic!"), outputs=gr.Label(num_top_classes=2, label="Sentiment"), title="🎬 Sentiment Analysis (DistilBERT)" ) if __name__ == "__main__": demo.launch()