Ujeshhh commited on
Commit
0b4918f
·
verified ·
1 Parent(s): 19441e0
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -1,22 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load pre-trained sentiment analysis model from Hugging Face
5
- sentiment_pipeline = pipeline("tabularisai/multilingual-sentiment-analysis")
6
 
7
  def analyze_sentiment(text):
8
  result = sentiment_pipeline(text)[0]
9
- label = result['label']
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=gr.Textbox(label="Sentiment Result"),
18
- title="Sentiment Analysis with Hugging Face 🤗",
19
- description="This app performs sentiment analysis on user input text using Hugging Face Transformers."
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__":