🚀 Lab MLOps • Hugging Face ⚡ Inférence Client Ultra-Rapide

Sentiment Analysis

Modèle DistilBERT fine-tuné pour l'analyse de polarité (Avis Positif vs Négatif)

Étudiant : Hassif HANNAN • Formation : MSI 4-27 DO A ISI PARIS
Exemples rapides :
Préchargement du modèle DistilBERT...

Résultat de la prédiction :

👍 POSITIVE
Sentiment Positif (POSITIVE) 99.8%
Sentiment Négatif (NEGATIVE) 0.2%

📦 Architecture MLOps & Code Python Gradio

Conformément aux consignes du TD, le code source Python Gradio (app.py) et les dépendances (requirements.txt) sont hébergés dans ce même dépôt Space.

import gradio as gr
from transformers import pipeline

# Modèle fine-tuné publié sur le Hub
MODEL_ID = "sdjlkfsdjsfjdl/distilbert-sentiment-analysis"
classifier = pipeline("sentiment-analysis", model=MODEL_ID, truncation=True)

def predict(text):
    preds = classifier(text, top_k=None)
    return {p["label"]: float(p["score"]) for p in preds}

demo = gr.Interface(fn=predict, inputs="text", outputs="label")
demo.launch()