AnkitPatil's picture
Update app.py
215422a
raw
history blame contribute delete
692 Bytes
import gradio as gr
from transformers import pipeline
# Load sentiment analysis pipeline
classifier = pipeline("sentiment-analysis")
# Gradio interface function
def analyze_sentiment(text):
result = classifier(text)
sentiment_label = result[0]['label']
confidence_score = result[0]['score']
return f"Sentiment: {sentiment_label}, Confidence: {confidence_score:.4f}"
# Create Gradio interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(),
outputs=gr.Textbox(),
live=True,
title="Sentiment Analysis App πŸ˜„πŸ˜‘πŸ˜πŸ˜ˆ",
description="Enter a text to analyze its sentiment."
)
# Launch the Gradio app
iface.launch(share=True)