razanalsulami commited on
Commit
d720951
1 Parent(s): 707c991

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the sentiment analysis pipeline
5
  sentiment_analysis = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
  # Function to analyze user's mood based on input
8
  def analyze_mood(user_input):
9
- # Analyze the mood from the input text
10
  result = sentiment_analysis(user_input)[0]
11
  # Define mood and suggestion based on sentiment analysis
12
  if result["label"] == "POSITIVE":
@@ -22,9 +22,7 @@ def analyze_mood(user_input):
22
  # Return mood and suggestion
23
  return "Your mood is: " + mood, suggestion
24
 
25
- # Define Gradio interface inputs and outputs directly without the '.inputs' or '.outputs' module
26
  inputs = gr.Textbox(label="How are you feeling today?", placeholder="Type your thoughts here...")
27
  outputs = gr.Textbox(label="Mood and Suggestion")
28
 
29
- # Create and launch the Gradio interface
30
- gr.Interface(fn=analyze_mood, inputs=inputs, outputs=outputs, title="Mood Analyzer").launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load sentiment analysis pipeline
5
  sentiment_analysis = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
  # Function to analyze user's mood based on input
8
  def analyze_mood(user_input):
9
+ # Analyze the mood from input text
10
  result = sentiment_analysis(user_input)[0]
11
  # Define mood and suggestion based on sentiment analysis
12
  if result["label"] == "POSITIVE":
 
22
  # Return mood and suggestion
23
  return "Your mood is: " + mood, suggestion
24
 
 
25
  inputs = gr.Textbox(label="How are you feeling today?", placeholder="Type your thoughts here...")
26
  outputs = gr.Textbox(label="Mood and Suggestion")
27
 
28
+ gr.Interface(fn=analyze_mood, inputs=inputs, outputs=outputs, title="Mood Analyzer").launch()