Spaces:
Sleeping

File size: 813 Bytes
662cc2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Load pre-trained sentiment analysis model
sentiment_model = pipeline("sentiment-analysis")

# Function to process input sentences and return sentiment
def get_sentiment(sentence):
    result = sentiment_model(sentence)
    sentiment_label = result[0]["label"]
    return sentiment_label

# Create Gradio UI components
input_text = gr.inputs.Textbox(lines=2, placeholder="Enter your sentence here...")
output_text = gr.outputs.Textbox()

# Create Gradio Interface
iface = gr.Interface(
    fn=get_sentiment,
    inputs=input_text,
    outputs=output_text,
    title="Sentiment Analysis",
    description="Enter a sentence to analyze its sentiment (positive, negative, or neutral)."
)

# Launch Gradio Interface
if __name__ == "__main__":
    iface.launch()