Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load sentiment analysis model
|
5 |
+
sentiment_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
|
6 |
+
|
7 |
+
# Function for sentiment analysis
|
8 |
+
def sentiment_analysis(text):
|
9 |
+
result = sentiment_pipeline(text)[0]
|
10 |
+
return f"Label: {result['label']}, Confidence: {round(result['score'], 4)}"
|
11 |
+
|
12 |
+
# Gradio Interface
|
13 |
+
demo = gr.Interface(fn=sentiment_analysis,
|
14 |
+
inputs=gr.Textbox(label="Enter Text"),
|
15 |
+
outputs=gr.Textbox(label="Sentiment Output"),
|
16 |
+
title="Multilingual Sentiment Analysis")
|
17 |
+
|
18 |
+
# Launch app locally
|
19 |
+
demo.launch()
|