Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
|
|
|
3 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
4 |
def analyze_sentiment(text):
|
5 |
result = sentiment_pipeline(text)[0]
|
@@ -7,7 +8,8 @@ def analyze_sentiment(text):
|
|
7 |
score = result["score"]
|
8 |
return f"Sentiment: {label}\nConfidence: {score:.2f}"
|
9 |
# Create the Gradio interface
|
10 |
-
|
|
|
11 |
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
12 |
outputs=gr.Textbox(),
|
13 |
title="Sentiment Analysis App",
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
# Load the sentiment analysis pipeline
|
4 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
5 |
def analyze_sentiment(text):
|
6 |
result = sentiment_pipeline(text)[0]
|
|
|
8 |
score = result["score"]
|
9 |
return f"Sentiment: {label}\nConfidence: {score:.2f}"
|
10 |
# Create the Gradio interface
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=analyze_sentiment,
|
13 |
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
14 |
outputs=gr.Textbox(),
|
15 |
title="Sentiment Analysis App",
|