Spaces:
Running
Running
app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
# Load
|
5 |
-
sentiment_pipeline = pipeline("sentiment-analysis", model="
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
-
result = sentiment_pipeline(text)
|
9 |
-
return result[
|
10 |
|
11 |
-
# Create a Gradio interface
|
12 |
iface = gr.Interface(
|
13 |
-
fn=analyze_sentiment,
|
14 |
-
inputs="
|
15 |
-
outputs="text",
|
16 |
-
title="Sentiment Analysis",
|
17 |
-
description="
|
18 |
)
|
19 |
|
20 |
-
|
21 |
-
iface.launch()
|
|
|
|
|
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__":
|
20 |
+
iface.launch()
|