Spaces:
Sleeping
Sleeping
File size: 625 Bytes
2284847 f206303 2284847 d16d710 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
# Load sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
def analyze_sentiment(text):
result = sentiment_pipeline(text)[0]
label = result['label']
score = result['score']
return f"Sentiment: {label} (confidence: {score:.2f})"
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
outputs="text",
title="Sentiment Analysis",
description="Enter text to analyze its sentiment (positive/negative)."
)
if __name__ == "__main__":
iface.launch()
|