This repository contains a Python script that demonstrates the creation and training of a real-time face mask detection system using deep learning techniques. The MobileNetV2 architecture is employed as a base model, with additional layers added for classification. The script preprocesses images, applies data augmentation, and uses an image data generator for training. The model is compiled and trained using the Adam optimizer. The performance is evaluated using a classification report, and the trained model is saved to disk. A plot showing training loss and accuracy over epochs is also generated.
To run the code and replicate the face mask detection system, follow these steps:
-
Install the required dependencies using the following commands: pip install tensorflow pip install keras
-
Download the code from this repository.
-
Download the dataset of face images with and without masks and organize it as follows:
- Create a directory named 'dataset'.
- Inside 'dataset', create subdirectories 'with_mask' and 'without_mask'.
- Place face images with masks in the 'with_mask' directory and images without masks in 'without_mask'.
- Run the Python script
mask_detection.py
using the following command:
For a detailed explanation and demonstration of the code, watch the video tutorial on YouTube: Face Mask Detection Video Tutorial
The script provides a real-time face mask detection system with accuracy and loss metrics displayed in a plot.
Pull requests are welcome! For major changes, please open an issue first to discuss the proposed changes.
This project is licensed under the MIT License.