This project provides a Flask-based web application for detecting stress levels using machine learning. Users can input various physiological parameters to get a stress level prediction.
There are two ways to use this project: training the model yourself using the provided Jupyter notebook, or using the pre-trained model via Docker.
-
Clone this repository:
git clone https://github.com/pouryare/Stress-level-detection.git cd stress-level-detection
-
Download the dataset:
- Visit Heart Rate Prediction to Monitor Stress Level on Kaggle
- Download the dataset files
-
Open and run the
Stress Level Detection.ipynb
notebook:- This notebook contains the code to train the model
- Follow the instructions within the notebook to train and save the model
-
After training, ensure the following files are in your project directory:
stress_detection_model.keras
scaler.joblib
-
Install the required Python packages:
pip install -r requirements.txt
-
Run the Flask application:
python main.py
-
Open a web browser and navigate to
http://localhost:8080
If you prefer to use the pre-trained model without going through the training process, you can use Docker:
-
Pull the Docker image:
docker pull pouryare/stress-level-detection:latest
-
Run the Docker container:
docker run -p 8080:8080 pouryare/stress-level-detection:latest
-
Open a web browser and navigate to
http://localhost:8080
Once the application is running:
-
You'll see input fields for various physiological parameters:
- MEAN_RR
- RMSSD
- pNN25
- pNN50
- LF
- HF
- LF_HF
-
Enter values for each parameter and click "Predict"
-
The application will display the predicted stress level: No Stress, Low Stress, or High Stress
main.py
: Main Flask application containing both the web server and model logicrequirements.txt
: List of Python dependenciesDockerfile
: Instructions for building the Docker imagetemplates/index.html
: HTML template for the web interfaceStress Level Detection.ipynb
: Jupyter notebook for model trainingstress_detection_model.keras
: Trained model filescaler.joblib
: Scaler for normalizing input data
This project was inspired by and builds upon the work of others in the field of stress detection using physiological signals. We acknowledge the contributions of the open-source community and the creators of the datasets and tools used in this project. Special thanks to Vinayak Shanawad for providing the dataset on Kaggle.
This project is for educational purposes only. While it aims to provide insights into stress levels based on physiological data, it should not be used as a substitute for professional medical advice, diagnosis, or treatment. Always consult with a qualified healthcare provider for any health-related concerns.