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:
bash
1# Make sure you have git-lfs installed (https://git-lfs.com)2git lfs install34# When prompted for a password, use an access token with write permissions.5# Generate one from your settings: https://huggingface.co/settings/tokens6git clone https://huggingface.co/aayush0/BertFineTunedSentiment
78# If you want to clone without large files - just their pointers9GIT_LFS_SKIP_SMUDGE=1git clone https://huggingface.co/aayush0/BertFineTunedSentiment
SSH:
bash
1# Make sure you have git-lfs installed (https://git-lfs.com)2git lfs install34# Make sure your SSH key is properly setup in your user settings.5# https://huggingface.co/settings/keys6git clone git@hf.co:aayush0/BertFineTunedSentiment
78# If you want to clone without large files - just their pointers9GIT_LFS_SKIP_SMUDGE=1git clone git@hf.co:aayush0/BertFineTunedSentiment
2. Create a virtual environment (optional but recommended)
bash
1python -m venv venv
2source venv/bin/activate # On Windows use `venv\Scripts\activate`
3. Install the required dependencies
pip install -r requirements.txt
The required dependencies include:
streamlit
torch
transformers
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).pth is 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.