Mental Health Status Prediction with BERT
This Streamlit web application predicts the mental health status from a given text input using a fine-tuned BERT model. The model classifies text into one of seven categories: Depression, Stress, Suicidal, Normal, Bipolar, Anxiety, and Personality Disorder.
Features
- BERT-based: Uses a pre-trained BERT model fine-tuned for sequence classification.
- Real-time prediction: Enter a sentence, and the model predicts the most likely mental health status.
- Interactive Interface: User-friendly interface built with Streamlit.
Installation
To run this project locally, follow these steps:
1. Clone this repository
HTTPS:
# Make sure you have git-lfs installed (https://git-lfs.com)
git lfs install
# When prompted for a password, use an access token with write permissions.
# Generate one from your settings: https://huggingface.co/settings/tokens
git clone https://huggingface.co/aayush0/BertFineTunedSentiment
# If you want to clone without large files - just their pointers
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/aayush0/BertFineTunedSentiment
SSH:
# Make sure you have git-lfs installed (https://git-lfs.com)
git lfs install
# Make sure your SSH key is properly setup in your user settings.
# https://huggingface.co/settings/keys
git clone git@hf.co:aayush0/BertFineTunedSentiment
# If you want to clone without large files - just their pointers
GIT_LFS_SKIP_SMUDGE=1 git clone git@hf.co:aayush0/BertFineTunedSentiment
2. Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
3. Install the required dependencies
pip install -r requirements.txt
The required dependencies include:
streamlittorchtransformers
4. Download the pre-trained BERT model and weights
The model and tokenizer will be downloaded automatically when running the app for the first time. You need to manually download and place the fine-tuned model weights in the project folder.
- Ensure that
sentiment_model_BERT (1).pthis in the root folder of your project.
5. Run the Streamlit app
streamlit run app.py
This will launch the app, and you can interact with it via your browser at http://localhost:8501.
Usage
- Enter a sentence in the text box.
- Click the Predict button.
- The model will display the predicted mental health status.
Model Details
The BERT model is fine-tuned for sequence classification with 7 labels, corresponding to different mental health statuses:
- Depression
- Stress
- Suicidal
- Normal
- Bipolar
- Anxiety
- Personality Disorder
License
This project is licensed under the MIT License - see the LICENSE file for details.