Asmatullah-AI-Engineer's picture
Upload app.py with huggingface_hub
0d97207 verified
raw
history blame contribute delete
581 Bytes
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()