Skip to content

msaad-dot/face-mask-detection

Repository files navigation

Face Mask Detection with Temperature Sensor and Gate Control

📌 Overview

This project detects whether a person is wearing a mask using a deep learning model and a real-time camera feed.
It also integrates with a temperature sensor and gate control system for automated access management.


✨ Features

  • Real-time face mask detection using a CNN model.
  • Face detection via OpenCV's Deep Learning-based SSD.
  • Temperature measurement via sensor integration.
  • Automatic gate control based on mask status and temperature.
  • High accuracy (99% on validation set).
  • Easy to train and customize with your own dataset.

📂 Project Structure

├── dataset/                # Images for training/testing (not included in repo)
├── models/                 # Pretrained models
│   ├── mask_detector.h5    # Trained mask detector model
│   └── face_detector/      # Face detection model files
│       ├── deploy.prototxt
│       └── res10_300x300_ssd_iter_140000.caffemodel
├── detection.py            # Mask detection script
├── gate_control.py         # Gate control logic
├── main.py                 # Main integration script
├── temperature_sensor.py   # Reads temperature from sensor
├── train_mask_detector.py  # Script to train the mask detector
├── utils.py                # Helper functions
├── plot.png                # Training loss/accuracy plot
├── requirements.txt        # Python dependencies
├── LICENSE                 # License file (MIT)
├── .gitignore              # Git ignore rules
└── README.md               # Project documentation

⚙️ Installation

  1. Clone the repository
git clone https://github.com/msaad-dot/face-mask-detection
cd face-mask-detection
  1. Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows
  1. Install dependencies
pip install -r requirements.txt

📦 Models

Face Detector Model

Download the files from OpenCV GitHub:

wget https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt
wget https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel

Mask Detector Model

Train your own model using:

python train_mask_detector.py

🚀 Usage

Run mask detection only:

python detection.py

Run full system with temperature sensor & gate:

python main.py

Train your own model:

python train_mask_detector.py

📊 Training Results

Training Plot


📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙌 Acknowledgements

About

An AI-powered access control solution that detects whether a person is wearing a face mask, measures body temperature, and controls gate entry accordingly. Built with Python, TensorFlow/Keras, and OpenCV, it integrates computer vision, deep learning, and IoT components to provide a fast and contactless safety check for secure environments.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages