Anisha0401 commited on
Commit
0ff342f
·
verified ·
1 Parent(s): 221fc61
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -1,18 +1,21 @@
 
1
  import gradio as gr
2
 
3
- # Define the function for sentiment analysis
 
 
4
  def analyze_sentiment(text):
5
  result = sentiment_pipeline(text)
6
- return result[0]["label"], result[0]["score"]
7
 
8
- # Create Gradio Interface
9
  iface = gr.Interface(
10
- fn=analyze_sentiment,
11
- inputs=gr.Textbox(lines=3, placeholder="Enter text here..."),
12
- outputs=[gr.Text(label="Sentiment"), gr.Text(label="Confidence Score")],
13
  title="Sentiment Analysis",
14
- description="Enter a sentence, and the model will predict its sentiment."
15
  )
16
 
17
- # Launch the Gradio app
18
- iface.launch()
 
1
+ from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Load the sentiment-analysis pipeline
5
+ sentiment_pipeline = pipeline("tabularisai/multilingual-sentiment-analysis")
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()