Real-Time Face Mask Detection
98% accuracy at 30 FPS · EfficientNet-B0 fine-tuned on MTCNN-aligned face crops for real-time mask/no-mask classification
Nov 2022
98%
Accuracy
30 FPS
Inference Speed
Problem
Detect mask/no-mask status from live webcam feeds with high accuracy and real-time latency — while remaining robust to varied face poses, lighting conditions, and partial occlusions that naive classifiers struggle with.
Approach
Built an MTCNN face detection and alignment pipeline to standardize face crops before classification — making the model invariant to pose and lighting shifts, and directly improving classification accuracy.
Fine-tuned EfficientNet-B0 on aligned crops for binary mask/no-mask classification, leveraging its lightweight architecture to maintain high accuracy without sacrificing inference speed.
Optimized the full inference pipeline end-to-end — MTCNN → crop → EfficientNet → overlay — achieving 30 FPS on a standard webcam without GPU bottlenecks.
Results
Achieved 98% classification accuracy on the held-out test set — surpassing the baseline EfficientNet fine-tune without alignment preprocessing.
Sustained 30 FPS inference on a standard webcam, enabling real-time deployment without specialized hardware.
Demonstrated robustness to varied face poses and lighting — directly attributable to MTCNN alignment as a preprocessing stage.
Architecture Overview
Webcam frame
MTCNN face detection + alignment
EfficientNet-B0 classification
Overlay (mask/no-mask label + confidence)
Real-time display
How to Run
Install: pip install tensorflow mtcnn opencv-pythonDownload pre-trained EfficientNet weights or train: python train.pyRun webcam demo: python demo.py --model checkpoints/best_model.h5Press Q to quit the webcam demo.