File size: 653 Bytes
ef18eae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Load sentiment analysis model
sentiment = pipeline("sentiment-analysis")

# Function to analyze text
def analyze_sentiment(text):
    if not text.strip():
        return "Please enter some text!"
    result = sentiment(text)[0]
    return f"Label: {result['label']}, Score: {round(result['score'], 2)}"

# Gradio interface
iface = gr.Interface(
    fn=analyze_sentiment,
    inputs=gr.Textbox(lines=5, placeholder="Type your text here..."),
    outputs="text",
    title="😊 Sentiment Analyzer",
    description="Type any text and see if it is Positive, Negative, or Neutral!"
)

iface.launch()