This program detects whether a person is wearing a face mask or not both in images, and in real-time video stream. Right now, this works only for one person wearing a mask in a frame. So there's room for improvement!
The dataset here was made by @prajnasb (Prajna's Github Repo) This dataset consists of 1,376 images belonging to two classes:
- with_mask: 690 images
- without_mask: 686 images
There are 3 python scripts in this repo:
- train_mask_detector.py: Accepts the input dataset and fine-tunes MobileNetV2 upon it to create the mask_detector.model. A training history plot.png containing accuracy/loss curves is also produced.
- detect_mask_image.py: Performs face mask detection in static images.
- detect_mask_video.py: Using the webcam, this script applies face mask detection to every frame in the stream.
-
Although the train_mask_detector.py script has been already run and its weights saved, you can still run it by opening the terminal/cmd in the script directory and typing this command:
python train_mask_detector.py --dataset dataset
-
To detect masks on a static image, run detect_mask_image.py in the terminal/cmd by typing:
python detect_mask_image.py --image images/example_01.png
-
To detect masks in real time, run detect_mask_video.py in the terminal/cmd by typing:
python detect_mask_video.py