Spaces:
Running
Running
File size: 821 Bytes
a788079 beaa23b a788079 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import gradio as gr
from transformers import pipeline
# Load model from Hugging Face
model_name = "MarieAngeA13/Sentiment-Analysis-BERT"
classifier = pipeline("sentiment-analysis", model=model_name)
# Prediction function
def predict_sentiment(text):
if text.strip() == "":
return "Please enter some text."
result = classifier(text)[0]
label = result["label"]
score = result["score"]
return f"Sentiment: {label} (Confidence: {score:.2f})"
# Gradio UI
iface = gr.Interface(
fn=predict_sentiment,
inputs=gr.Textbox(lines=5, placeholder="Enter your review here..."),
outputs="text",
title="Sentiment Analysis App",
description="Enter a review to classify it as Positive or Negative using a Hugging Face model."
)
# Launch app
if __name__ == "__main__":
iface.launch() |