Spaces:
Sleeping
Sleeping
File size: 780 Bytes
562ec28 464023f 562ec28 464023f 562ec28 806b724 464023f 806b724 562ec28 464023f 806b724 464023f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import gradio as gr
from transformers import pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
def analyze_sentiment(text):
result = sentiment_pipeline(text)[0]
return f"Sentiment: {result['label']} (Confidence: {result['score']:.2f})"
custom_css = """
#interface-container {background-color: #f8f9fa;}
#title {color: #2c3e50; font-size: 24px;}
"""
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter Text", placeholder="Type your sentence here..."),
outputs=gr.Text(label="Sentiment Analysis Result"),
title="Sentiment Analysis API",
description="🔍 Enter a sentence, and the model will predict if it's POSITIVE or NEGATIVE.",
theme="compact",
css=custom_css
)
# Launch the Gradio app
iface.launch()
|