This project aims to create a Face Mask Detection model to visually detect facemasks on images and videos. We operate with 3 labels:
- with_mask
- without_mask
- mask_weared_incorrect
The dataset contains approximately 2500 hand-collected and hand-labelled images.
Results:
Models | mAP | with_mask | without_mask | mask_weared_incorrect | FPS (RTX 3060 Ti + CUDA) |
---|---|---|---|---|---|
ResNet50 | 68% | 81% | 67% | 56% | ~20 |
ResNet152 | 66% | 81% | 65% | 52% | ~12 |
How good are the models? This good:
Table of Contents
- Clone the repo
git clone https://github.com/DvdNss/FaceMaskDetection
- Install requirements
pip install -r requirements.txt
- Clone PyTorch-Retinanet
git clone https://github.com/yhenon/pytorch-retinanet.git
dataset/
: contains datasets filesretinanet/
: contains retinanet scriptsmodel/
: contains modelsresources/
: contains readme and webapp imagesannots_to_csv.py
: script for datasets conversion to csvfile_conversion.py
: script for png conversion to jpgdevice.py
: script for device detection (gpu or cpu)precompute_dataset.py
: script for dataset precomputingapp.py
: streamlit webapp
- Convert datasets to csv file using
annots_to_csv.py
python annots_to_csv.py --train_dataset path_to_train_dataset --valid_dataset path_to_valid_dataset --output_path path_of_outputs
- Train a given model using
pytorch-retinanet/train.py
cd pytorch-retinanet
python train.py --dataset csv --csv_train path_to_train_csv --csv_classes path_to_class_csv --csv_val path_to_valid_csv --depth depth_of_resnset --epochs number_of_epochs
- Evaluate a given model using
pytorch-retinanet/csv_evaluation.py
cd pytorch-retinanet
python csv_validation.py --csv_annotations_path path_to_val_annots --model_path model_path --images_path path_to_val_img --class_list_path path_to_labels
- Visualize result using
pytorch-retinanet/visualize_single_image.py
cd pytorch-retinanet
python visualize_single_image.py --image_dir image_dir_path --model_path model_path --class_list labels_path
- Use the interface (webcam or images)
streamlit run app.py
David NAISSE - @LinkedIn - [email protected]