Spaces:
Running
Running
app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,21 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
|
|
|
|
4 |
def analyze_sentiment(text):
|
5 |
result = sentiment_pipeline(text)
|
6 |
-
return result[0]
|
7 |
|
8 |
-
# Create Gradio
|
9 |
iface = gr.Interface(
|
10 |
-
fn=analyze_sentiment,
|
11 |
-
inputs=
|
12 |
-
outputs=
|
13 |
title="Sentiment Analysis",
|
14 |
-
description="Enter
|
15 |
)
|
16 |
|
17 |
-
# Launch the
|
18 |
-
iface.launch()
|
|
|
1 |
+
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# Load the sentiment-analysis pipeline
|
5 |
+
sentiment_pipeline = pipeline("tabularisai/multilingual-sentiment-analysis")
|
6 |
+
|
7 |
def analyze_sentiment(text):
|
8 |
result = sentiment_pipeline(text)
|
9 |
+
return result[0]
|
10 |
|
11 |
+
# Create a Gradio interface
|
12 |
iface = gr.Interface(
|
13 |
+
fn=analyze_sentiment,
|
14 |
+
inputs="text",
|
15 |
+
outputs="text",
|
16 |
title="Sentiment Analysis",
|
17 |
+
description="Enter some text to analyze its sentiment."
|
18 |
)
|
19 |
|
20 |
+
# Launch the interface
|
21 |
+
iface.launch()
|