Spaces:
Running
Running
Upload app.py
Browse files
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
|
| 47 |
-
["I'
|
| 48 |
-
["
|
|
|
|
| 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 |
|