Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load
|
5 |
-
sentiment_pipeline = pipeline("tabularisai/multilingual-sentiment-analysis")
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
result = sentiment_pipeline(text)[0]
|
9 |
-
|
10 |
-
score = round(result['score'], 3)
|
11 |
-
return f"Sentiment: {label} | Confidence: {score}"
|
12 |
|
13 |
-
# Gradio UI
|
14 |
iface = gr.Interface(
|
15 |
fn=analyze_sentiment,
|
16 |
inputs=gr.Textbox(label="Enter Text"),
|
17 |
-
outputs=
|
18 |
-
title="Sentiment Analysis
|
19 |
-
description="
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load multilingual sentiment model
|
5 |
+
sentiment_pipeline = pipeline("sentiment-analysis", model="tabularisai/multilingual-sentiment-analysis")
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
result = sentiment_pipeline(text)[0]
|
9 |
+
return f"{result['label']} ({round(result['score'], 2)})"
|
|
|
|
|
10 |
|
|
|
11 |
iface = gr.Interface(
|
12 |
fn=analyze_sentiment,
|
13 |
inputs=gr.Textbox(label="Enter Text"),
|
14 |
+
outputs="text",
|
15 |
+
title="Multilingual Sentiment Analysis 🌐",
|
16 |
+
description="Analyze text sentiment in multiple languages using Hugging Face."
|
17 |
)
|
18 |
|
19 |
if __name__ == "__main__":
|