AlphamanKing commited on
Commit
64962af
·
verified ·
1 Parent(s): 1c56924

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -2,6 +2,11 @@ import gradio as gr
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
  import torch.nn.functional as F
 
 
 
 
 
5
 
6
  # Load MentalBERT model & tokenizer
7
  MODEL_NAME = "mental/mental-bert-base-uncased"
@@ -41,11 +46,12 @@ iface = gr.Interface(
41
  inputs=gr.Textbox(label="Enter text to analyze", lines=3),
42
  outputs=gr.Json(label="Emotion Analysis"),
43
  title="MentalBERT Emotion Analysis",
44
- description="Analyze the emotional content of text using MentalBERT",
45
  examples=[
46
- ["I feel really happy today!"],
47
- ["I'm feeling quite stressed and overwhelmed"],
48
- ["The weather is nice outside"]
 
49
  ]
50
  )
51
 
 
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
  import torch.nn.functional as F
5
+ from huggingface_hub import login
6
+ import os
7
+
8
+ # Authenticate with Hugging Face using token from environment variable
9
+ login(os.environ.get("HUGGINGFACE_TOKEN"))
10
 
11
  # Load MentalBERT model & tokenizer
12
  MODEL_NAME = "mental/mental-bert-base-uncased"
 
46
  inputs=gr.Textbox(label="Enter text to analyze", lines=3),
47
  outputs=gr.Json(label="Emotion Analysis"),
48
  title="MentalBERT Emotion Analysis",
49
+ description="Analyze the emotional content of text using MentalBERT (specialized for mental health content)",
50
  examples=[
51
+ ["I feel really anxious about my upcoming presentation"],
52
+ ["I've been feeling quite depressed lately"],
53
+ ["I'm managing my stress levels well today"],
54
+ ["Just had a great therapy session!"]
55
  ]
56
  )
57