Spaces:
Sleeping
Sleeping
File size: 616 Bytes
bcc24ce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from transformers import pipeline
import gradio as gr
# Load sentiment analysis pipeline
classifier = pipeline("sentiment-analysis")
def analyze_sentiment(text):
result = classifier(text)[0]
label = result['label']
score = round(result['score'] * 100, 2)
return f"Sentiment: {label} (Confidence: {score}%)"
# Create Gradio interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter text"),
outputs=gr.Textbox(label="Sentiment Result"),
title="Sentiment Analyzer",
description="Enter a sentence and see if it's positive or negative."
)
iface.launch()
|