taimoor61 commited on
Commit
29c65a1
·
1 Parent(s): 5d4738f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -1,8 +1,5 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
- import emoji
4
- pip install emoji
5
-
6
 
7
  # Load pre-trained emotion classification model
8
  model_checkpoint = "MuntasirHossain/RoBERTa-base-finetuned-emotion"
@@ -25,20 +22,19 @@ def classify_and_visualize_emotion(text):
25
  # Get the corresponding emoji for the predicted emotion
26
  predicted_emoji = emoji_mapping.get(emotion_label, "🤔")
27
 
28
- # Construct the result string with the predicted emotion and emoji
29
- result_text = f"Predicted Emotion: {emotion_label.capitalize()} {predicted_emoji}"
30
-
31
- return result_text
32
 
33
  # Define interface title and description
34
  title = "Emotion Classifier with Emoji Visualization"
35
  description = "This AI model classifies text expressions into six emotions: joy, sadness, love, anger, fear, and surprise. The result is visualized with emojis."
36
 
37
- # Set up Gradio Interface
38
- gr.Interface(
39
  fn=classify_and_visualize_emotion,
40
  inputs="textbox",
41
- outputs="html",
42
  title=title,
43
  description=description,
44
- ).launch()
 
 
 
1
  from transformers import pipeline
2
  import gradio as gr
 
 
 
3
 
4
  # Load pre-trained emotion classification model
5
  model_checkpoint = "MuntasirHossain/RoBERTa-base-finetuned-emotion"
 
22
  # Get the corresponding emoji for the predicted emotion
23
  predicted_emoji = emoji_mapping.get(emotion_label, "🤔")
24
 
25
+ return f"{emotion_label.capitalize()} {predicted_emoji}"
 
 
 
26
 
27
  # Define interface title and description
28
  title = "Emotion Classifier with Emoji Visualization"
29
  description = "This AI model classifies text expressions into six emotions: joy, sadness, love, anger, fear, and surprise. The result is visualized with emojis."
30
 
31
+ # Set up Gradio Interface with HTML visualization
32
+ iface = gr.Interface(
33
  fn=classify_and_visualize_emotion,
34
  inputs="textbox",
35
+ outputs=gr.Html(),
36
  title=title,
37
  description=description,
38
+ )
39
+
40
+ iface.launch()