A newer version of the Gradio SDK is available:
5.45.0
title: Mental Health Emotion Classifier
emoji: ๐ง
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 4.29.0
app_file: app.py
pinned: false
NOTE: Running the app in the space is taking a lot of time for model inference. I suggest you to download the model and app files and run the app locally.
You can download the model from this Hugging Face Hub link: https://huggingface.co/Hrishikesh4/mental-health-classifier-longformer.
Mental Health Sentiment Analyzer App
The Mental Health Sentiment Analyzer is an AI-powered application that analyzes user text to detect potential signs of mental health states such as depression, anxiety, and stress. The app leverages a fine-tuned Longformer model for multi-label text classification, built with Hugging Face Transformers, and provides explainable predictions with SHAP, along with concise summaries using Cohere API.
This project is deployed on Hugging Face Spaces with a Gradio-based interface.
๐ Features
- Multi-label classification of user text into categories: depression, anxiety, stress, neutral.
- Explainable AI: SHAP visualizations for understanding model predictions.
- Summary generation for analyzed text using Cohere API.
- User-friendly web interface built with Gradio.
- Deployable on Hugging Face Spaces.
๐ ๏ธ Tech Stack
- Language Model: Fine-tuned Longformer
- Summarization: Cohere API
- Frameworks: Hugging Face Transformers, PyTorch
- Interface: Gradio
- Explainability: SHAP
- Deployment: Hugging Face Spaces
๐ Project Structure
Mental-Health-Sentiment-Analyzer/
โ
โโโ app/
โ โโโ gradio_interface.py # Gradio UI definition
โ โโโ models/ # Trained model files
โ โ โโโ __init__.py
โ โ โโโ best_thresholds.json
โ โ โโโ sentiment_model.py
โ โโโ utils/ # Explanation and summarizer files
โ โ โโโ __init__.py
โ โ โโโ shap_explainer.py
โ โ โโโ text_summarizer.py
โ
โโโ requirements.txt # Dependencies
โโโ app.py # Entry point for Hugging Face Spaces
โโโ README.md # Project documentation
Fine-tuned Model Details
You can access the fine-tuned Longformer model's at this Hugging Face Model link: https://huggingface.co/Hrishikesh4/mental-health-classifier-longformer
๐ค Contributors
- Hrishikesh Kurapati (Lead Developer)
๐ License
mit
๐ฎ Future Work
- Add support for more mental health categories.
- Improve explainability features.
- Expand dataset for better generalization.
๐ Acknowledgements
- Hugging Face for Transformers & Spaces.
- Gradio for interactive UI.
โThe model is designed for early detection of mental health risks and can be integrated into wellness or therapy support applications. It works by analyzing a userโs voluntary text inputs โ such as journals, self-reflections, or chatbot interactions โ and identifying patterns of stress, anxiety, or depression. Depending on the userโs consent settings, it can either provide self-help recommendations, notify a therapist, or in high-risk cases, alert a pre-approved emergency contact. The goal is to empower timely intervention while ensuring privacy and ethical use.โ