Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Live Mask Detection & Social Distancing System

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.

Features

  • 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).

Getting Started

Prerequisites

  • Python 3.7+
  • A webcam

Installation

  1. Clone the Repository

    git clone https://github.com/your-username/Mask_detection.git
    cd Mask_detection
  2. Install Dependencies

    pip install -r requirements.txt

Model Setup (Critical)

This system requires a trained model to detect masks. You have two options:

Option A: Train Your Own Model (Recommended for "Best Accuracy")

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 dataset

This will generate models/mask_detector.model.

Option B: Use a Pre-trained 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.

Usage

Start the live monitoring system:

python main.py
  • Q: Quit the application.

Configuration

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).

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages