Spaces:
Sleeping
Sleeping
File size: 645 Bytes
d898436 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
# Load Sentiment Analysis Model
sentiment_pipeline = pipeline("sentiment-analysis")
# Define Function for Prediction
def analyze_sentiment(text):
result = sentiment_pipeline(text)
return result[0]["label"], result[0]["score"]
# Create Gradio Interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter Text"),
outputs=[gr.Textbox(label="Sentiment"), gr.Textbox(label="Confidence Score")],
title="Sentiment Analysis App",
description="Enter a sentence and get its sentiment (Positive/Negative).",
)
iface.launch()
|