Spaces:
Sleeping
Sleeping
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) | |