Ujeshhh commited on
Commit
aaf19ed
·
verified ·
1 Parent(s): a3b2c96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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()