A robust, real-time AI system designed to ensure safety compliance. It detects face masks, monitors social distancing using Euclidean distance tracking, and visualizes risks with dynamic heatmaps and augmented reality body segmentation.
- Accurate Mask Detection: Uses MobileNetV2 architecture for lightweight, high-accuracy classification.
- Social Distancing Alerts: Mathematically computes pairwise distances to identify unsafe proximity.
- Smart Visualization:
- Heatmaps: A glowing overlay highlights violation clusters in real-time.
- Status Indicators: Green/Red bounding boxes and connection lines.
- Body Segmentation: Focuses on subjects by blurring the background (optional).
- Python 3.7+
- A webcam
-
Clone the Repository
git clone https://github.com/your-username/Mask_detection.git cd Mask_detection -
Install Dependencies
pip install -r requirements.txt
This system requires a trained model to detect masks. You have two options:
We have provided a training script. You will need a dataset of images with "with_mask" and "without_mask" folders.
# Structure your data:
# dataset/
# with_mask/
# without_mask/
# Run the training script:
python train_mask_detector.py --dataset datasetThis will generate models/mask_detector.model.
If you have a mask_detector.model file (MobileNetV2 format), simply place it in the models/ directory.
Note: If no model is found, the system runs in "Face Detection Only" mode for demo purposes, where all faces are treated as "No Mask" to ensure safety alerts are visible.
Start the live monitoring system:
python main.py- Q: Quit the application.
Edit utils/config.py to fine-tune the system:
MIN_DISTANCE: Adjust pixel threshold based on your camera's field of view (default: 50).MIN_CONFIDENCE: Adjust detection sensitivity (default: 0.5).
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request