How chandrikadeb7/face-mask-detection works
Project Type & Purpose
• This is a machine-learning‐powered computer vision system for face-mask detection. It includes:
• A training pipeline (TensorFlow/Keras + transfer learning on MobileNetV2, ResNet50_v2, InceptionV3)
• An inference/detection pipeline (OpenCV+Caffe face detector + mask‐vs‐no‐mask classifier)
• A simple web interface served via Streamlit (app.py)
• Utility scripts for dataset creation (search.py), model conversion (model2onnx.py), and Raspberry Pi/IoT setup
File Structure Analysis
TOP-LEVEL
• dataset/with_mask & dataset/without_mask – raw images
• face_detector/ – Caffe prototxt + weights for face detection
• incep_v3_mask_model/ + ResNet50_v2/ – Jupyter notebooks & helper scripts for alternative training runs
• train_mask_detector.py – main CLI training entrypoint
• detect_mask_image.py / detect_mask_video.py – standalone inference scripts
• model2onnx.py – converts the .model to ONNX for cross‐platform serving
• mask_detector.model – serialized Keras/TensorFlow classifier
• app.py + css/ – Streamlit webapp for real-time detection in browser
• requirements.txt – declared dependencies (OpenCV, TensorFlow, Keras, Streamlit, etc.)
README Insights
• Confirms use of MobileNetV2 (transfer learning), TensorFlow‐GPU, OpenCV DNN
• Demonstrates CLI usage, Python scripts for training/inference, and webapp commands
• Includes IoT section for Raspberry Pi deployment
Diagramming the Architecture
1. Data Store
– dataset/with_mask, dataset/without_mask
2. Training Pipeline
– train_mask_detector.py
– Helper notebooks (incep_v3_mask_model/, ResNet50_v2/)
– Outputs: mask_detector.model (and ONNX via model2onnx.py)
3. Face‐Detector Submodule
– Caffe model in face_detector/ (deploy.prototxt + .caffemodel)
4. Inference Pipelines
– CLI scripts (detect_mask_image.py, detect_mask_video.py)
– Streamlit Webapp (app.py + css/)
5. External/Edge Deployment
– Raspberry Pi + PiCamera (per README IoT section)
6. External Services & Clients
– Browser (Streamlit UI)
– DevOps: (Heroku/Gumroad links for demo/deployment)
• Raw Images → Training Pipeline → Trained Model (.model / .onnx)
• Trained Model + Face-Detector Caffe Model → Inference Engine
• Inference Engine → CLI Output / Streamlit Frontend → End User Display
• (Optional) Trained Model + Inference Engine → Raspberry Pi for Edge Deployment
c. Architectural Patterns & Principles
• Modular separation: data, training, model conversion, inference, UI
• Pipeline pattern for training vs. inference stages
• Single‐page interactive webapp (Streamlit) vs. standalone CLI tools
• Reusability: face detector and classifier are independent modules
d. Key Technologies & Frameworks
• Python 3.6+, OpenCV DNN (Caffe), TensorFlow/Keras, MobileNetV2, ONNX
• Streamlit for web UI
• Virtualenv / requirements.txt for environment management
• (Optional) Raspberry Pi dependencies for edge deployment