Spaces:
Build error
Build error
black shadow commited on
Commit ·
d898436
1
Parent(s): 02972ad
Hugging Face Project✅
Browse files123456789101112131415161718192021import 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()app.pyAdded+21