⚠ The Challenge
Manufacturing facilities needed automated mask compliance monitoring on standard CPU hardware. 3-class detection — correctly worn, incorrectly worn, not worn — with high accuracy for each.
💡 The Approach
MobileNetV2 transfer learning for fast CPU inference. 2-phase fine-tuning. Aggressive data augmentation to handle different lighting conditions, angles, and face sizes in real environments.
🔄 Step-by-Step Process
Collected dataset with 3 classes: with_mask, without_mask, mask_weared_incorrect
Applied data augmentation: horizontal flip, rotation ±15°, zoom 0.1, brightness shifts
Phase 1: Trained MobileNetV2 classification head with base frozen — accuracy ~92%
Phase 2: Fine-tuned last 20 MobileNetV2 layers — accuracy improved to 95%+
Built real-time webcam detection with color-coded bounding boxes per class
Added compliance rate tracker showing percentage of correctly masked people in frame
✓ Final Result
95%+ accuracy across all 3 classes. Real-time detection at 15+ FPS on CPU. Color-coded alerts make violations immediately visible. Compliance percentage gives management actionable metrics.
📚 Key Lesson
3-class mask detection is significantly harder than binary. The incorrectly-worn class is visually similar to both other classes, requiring careful augmentation to differentiate reliably.
