Hrishikesh4's picture
Update README.md
6a660a7 verified

A newer version of the Gradio SDK is available: 5.45.0

Upgrade
metadata
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.โ€