Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the sentiment
|
5 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
6 |
|
7 |
-
#
|
8 |
def analyze_sentiment(text):
|
9 |
result = sentiment_analyzer(text)
|
10 |
sentiment = result[0]['label']
|
11 |
score = result[0]['score']
|
12 |
return f"Sentiment: {sentiment} (Confidence: {score:.2f})"
|
13 |
|
14 |
-
#
|
15 |
app = gr.Interface(
|
16 |
fn=analyze_sentiment,
|
17 |
inputs=gr.Textbox(label="Enter text to analyze"),
|
18 |
outputs=gr.Textbox(label="Sentiment Analysis Result"),
|
19 |
title="Text Sentiment Analyzer",
|
20 |
-
description="
|
21 |
)
|
22 |
|
23 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the sentiment analysis model
|
5 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
6 |
|
7 |
+
# Function to analyze text sentiment
|
8 |
def analyze_sentiment(text):
|
9 |
result = sentiment_analyzer(text)
|
10 |
sentiment = result[0]['label']
|
11 |
score = result[0]['score']
|
12 |
return f"Sentiment: {sentiment} (Confidence: {score:.2f})"
|
13 |
|
14 |
+
# Gradio interface
|
15 |
app = gr.Interface(
|
16 |
fn=analyze_sentiment,
|
17 |
inputs=gr.Textbox(label="Enter text to analyze"),
|
18 |
outputs=gr.Textbox(label="Sentiment Analysis Result"),
|
19 |
title="Text Sentiment Analyzer",
|
20 |
+
description="A simple app that analyzes the sentiment of your text input."
|
21 |
)
|
22 |
|
23 |
if __name__ == "__main__":
|