ZENLLC commited on
Commit
c40ac19
·
verified ·
1 Parent(s): 909ea11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,23 +1,23 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the sentiment-analysis pipeline
5
  sentiment_analyzer = pipeline("sentiment-analysis")
6
 
7
- # Define the function to analyze text sentiment
8
  def analyze_sentiment(text):
9
  result = sentiment_analyzer(text)
10
  sentiment = result[0]['label']
11
  score = result[0]['score']
12
  return f"Sentiment: {sentiment} (Confidence: {score:.2f})"
13
 
14
- # Create the Gradio interface
15
  app = gr.Interface(
16
  fn=analyze_sentiment,
17
  inputs=gr.Textbox(label="Enter text to analyze"),
18
  outputs=gr.Textbox(label="Sentiment Analysis Result"),
19
  title="Text Sentiment Analyzer",
20
- description="Analyze the sentiment of text input using a pre-trained NLP model."
21
  )
22
 
23
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the sentiment analysis model
5
  sentiment_analyzer = pipeline("sentiment-analysis")
6
 
7
+ # Function to analyze text sentiment
8
  def analyze_sentiment(text):
9
  result = sentiment_analyzer(text)
10
  sentiment = result[0]['label']
11
  score = result[0]['score']
12
  return f"Sentiment: {sentiment} (Confidence: {score:.2f})"
13
 
14
+ # Gradio interface
15
  app = gr.Interface(
16
  fn=analyze_sentiment,
17
  inputs=gr.Textbox(label="Enter text to analyze"),
18
  outputs=gr.Textbox(label="Sentiment Analysis Result"),
19
  title="Text Sentiment Analyzer",
20
+ description="A simple app that analyzes the sentiment of your text input."
21
  )
22
 
23
  if __name__ == "__main__":