Anisha0401 commited on
Commit
0e69a9a
·
verified ·
1 Parent(s): b431a98
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -1,21 +1,20 @@
1
- from transformers import pipeline
2
  import gradio as gr
 
3
 
4
- # Load the sentiment-analysis pipeline
5
- sentiment_pipeline = pipeline("sentiment-analysis", model="nlptown/bert-base-multilingual-uncased-sentiment")
6
 
7
  def analyze_sentiment(text):
8
- result = sentiment_pipeline(text)
9
- return result[0]
10
 
11
- # Create a Gradio interface
12
  iface = gr.Interface(
13
- fn=analyze_sentiment,
14
- inputs="text",
15
- outputs="text",
16
- title="Sentiment Analysis",
17
- description="Enter some text to analyze its sentiment."
18
  )
19
 
20
- # Launch the interface
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()