File size: 581 Bytes
0d97207 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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()
|