| import gradio as gr | |
| from transformers import pipeline | |
| classifier = pipeline( | |
| "text-classification", | |
| model="Asmatullah-AI-Engineer/distilbert-imdb-sentiment" | |
| ) | |
| def predict(text): | |
| result = classifier(text)[0] | |
| label = result["label"] | |
| score = result["score"] | |
| return f"{label} (confidence: {score:.3f})" | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(placeholder="Enter a movie review..."), | |
| outputs=gr.Textbox(label="Sentiment"), | |
| title="Movie Sentiment Classifier", | |
| description="Fine-tuned DistilBERT on IMDb reviews" | |
| ) | |
| demo.launch() | |