Spaces:
Sleeping
Sleeping
File size: 593 Bytes
2ed5863 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # app.py — upload this file to your Hugging Face Space
import gradio as gr
from transformers import pipeline
model_name = "msfasha/distilbert-sentiment-imdb-small"
classifier = pipeline("sentiment-analysis", model=model_name)
def predict_sentiment(text):
result = classifier(text)[0]
return f"Label: {result['label']}, Confidence: {round(result['score'], 3)}"
interface = gr.Interface(
fn=predict_sentiment,
inputs="text",
outputs="text",
title="Sentiment Analysis",
description="Enter a movie review to classify as POSITIVE or NEGATIVE."
)
interface.launch() |