The project is a face mask detection system that uses OpenCV for face detection and a Keras/TensorFlow model to classify whether a person is wearing a mask. The project demonstrates real-time video processing and deep learning-based classification. This project was originally developed as part of my college assignment. The current version has been organized and uploaded to GitHub for reference.
⚠️ Heads up: This project is meant mostly for showcasing. If you try to run it, brace yourself for some dependency and setup adventures.
- Detect faces in images or video streams.
- Predict if a detected face is wearing a mask or not.
- OpenCV DNN used for face detection.
Face-Mask-Detection/
├── dataset/ # Images used for training
├── face_detector/ # Pre-trained face detection models (Caffe)
│ ├── deploy.prototxt
│ └── res10_300x300_ssd_iter_140000.caffemodel
├── detect_mask.py # Real-time mask detection script
├── train_mask_detector.py # Script to train mask detection model
├── mask_detector.h5 # Trained model (generated after training. # Trained model (was originally mask_detector.model, now converted to H5 format)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
-
Clone the repository:
git clone <repo-url> cd Face-Mask-Detection
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # Linux / macOS venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Ensure these files exist:
face_detector/deploy.prototxt
face_detector/res10_300x300_ssd_iter_140000.caffemodel
If missing or corrupted, grab them from OpenCV's GitHub: Face Detector Model Files
-
Run detection (optional):
python3 detect_mask.py
If it runs, congratulations! If not, welcome to dependency hell. 😅
-
Developed for academic learning and demonstration.
-
Training the model is resource-intensive.
-
Cloning and running may require some patience and debugging.
-
Model training parameters were slightly adjusted from the original college version.