This project detects whether a person is wearing a mask using a deep learning model and a real-time camera feed.
It also integrates with a temperature sensor and gate control system for automated access management.
- Real-time face mask detection using a CNN model.
- Face detection via OpenCV's Deep Learning-based SSD.
- Temperature measurement via sensor integration.
- Automatic gate control based on mask status and temperature.
- High accuracy (99% on validation set).
- Easy to train and customize with your own dataset.
├── dataset/ # Images for training/testing (not included in repo)
├── models/ # Pretrained models
│ ├── mask_detector.h5 # Trained mask detector model
│ └── face_detector/ # Face detection model files
│ ├── deploy.prototxt
│ └── res10_300x300_ssd_iter_140000.caffemodel
├── detection.py # Mask detection script
├── gate_control.py # Gate control logic
├── main.py # Main integration script
├── temperature_sensor.py # Reads temperature from sensor
├── train_mask_detector.py # Script to train the mask detector
├── utils.py # Helper functions
├── plot.png # Training loss/accuracy plot
├── requirements.txt # Python dependencies
├── LICENSE # License file (MIT)
├── .gitignore # Git ignore rules
└── README.md # Project documentation
- Clone the repository
git clone https://github.com/msaad-dot/face-mask-detection
cd face-mask-detection- Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows- Install dependencies
pip install -r requirements.txtDownload the files from OpenCV GitHub:
wget https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt
wget https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodelTrain your own model using:
python train_mask_detector.pyRun mask detection only:
python detection.pyRun full system with temperature sensor & gate:
python main.pyTrain your own model:
python train_mask_detector.pyThis project is licensed under the MIT License - see the LICENSE file for details.
- OpenCV
- Keras
- TensorFlow
- Dataset sources from various public mask datasets.
