Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
|
2 |
-
|
3 |
# Load the sentiment analysis pipeline
|
4 |
-
|
5 |
-
|
6 |
result = sentiment_pipeline(text)[0]
|
7 |
label = result["label"]
|
8 |
score = result["score"]
|
9 |
return f"Sentiment: {label}\nConfidence: {score:.2f}"
|
10 |
|
11 |
# Create the Gradio interface
|
12 |
-
|
13 |
fn=analyze_sentiment,
|
14 |
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
15 |
outputs=gr.Textbox(),
|
@@ -21,5 +21,5 @@
|
|
21 |
]
|
22 |
)
|
23 |
# Launch the app
|
24 |
-
|
25 |
iface.launch()
|
|
|
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]
|
7 |
label = result["label"]
|
8 |
score = result["score"]
|
9 |
return f"Sentiment: {label}\nConfidence: {score:.2f}"
|
10 |
|
11 |
# Create the Gradio interface
|
12 |
+
iface = gr.Interface(
|
13 |
fn=analyze_sentiment,
|
14 |
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
15 |
outputs=gr.Textbox(),
|
|
|
21 |
]
|
22 |
)
|
23 |
# Launch the app
|
24 |
+
if __name__ == "__main__":
|
25 |
iface.launch()
|