vipul43 / Face_Mask_Detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Face Mask Detection

Detecting the faces of the people in the scene and classify them as with mask and without mask.
The main task of face mask detection is divided into two subtasks. Face Detection task and Mask Classification task. In the former one, faces of humans from a scene(usually with high background noise) is detected. The detected faces are passed as input to the latter task, where the detected faces with mask and detected faces without mask are classified. More Details are provided in the subsequent sections on the tasks.

Face Detection Using RetinaFace and OpenCV

[branch retinaNet]
Pre-trained RetinaFace model is used for face detection task. Open Source Python Package Index implementation available here is used.

Implementations of RetinaFace

The open source official implementation of RetinaFace can be found here. The next popular implementation which is also available as a Python Package Index is by Vladimir Iglovikov@ternaus which is available here. This implementation is build from biubug6 implmentation, available here. Which is inturn build up on the official implementation.

Both the Python Package Index implementations are tested on a single crowd image with many people in it. retinaface-pytorch implemenation crossed the retinaface implmentation by a huge margin. Only 81 faces were detected in the retinface implementation whereas 416 images were detected in the retinaface-pytorch implementation. But there is also a drawback of time. Both the implementations perform single forward pass through the dataset, but retinaface implementation is a tad faster then retinaface-pytorch. The test results can be found here.

More About retinaface-pytorch

The model is trained and validated on WIDERFACE dataset along with validation in FDDB. PyTorch Lightning module is used in the implmentation. RetinaFace in this implementation is build on the ResNet50 backbone. The following features are available in the implementation

vis_annotations(image: np.ndarray, annotations: List[Dict[str, Any]]) -> np.ndarray # utils.py, to draw faces and landmarks on detected faces
model.eval() # to give out the evaluation result
model.predict_jsons(image: np.array, confidence_threshold: float = 0.7, nms_threshold: float = 0.4) # to make predictions and return list of faces, landmarks and confidence score
get_model(model_name: str, max_size: int, device: str = "cpu") -> Model # returns pre-trained model for usage

Mask Classification Using Deep Learning

Convolutional Neural Network to tackel the binary classification problem of classifying face images into two classes, with mask(label=0) and with out mask(label=1). Evaluating the model on the validation dataset by calculating loss, accuracy, f1 score, precision and recall.

Dataset

Real World Masked Face Detection(RWMFD) Dataset

Download here
Dataset contains unlabelled images of people with and without mask(typically with heavy background noise). This dataset contains 4194 unlabelled images. This dataset is intended only for testing purposes and not for training. This dataset is extracted from the open source dataset Real-World-Masked-Face-Dataset as part of Open Ended Lab Project at IIT Palakkad. Further details about the dataset can be found in the README file present in the dataset.

Face Mask ~12K Dataset

Download here
Dataset contains labelled images of people's faces with masks and without masks. This dataset is intended to train Mask Classification Model. It contains 11784 images, 5883 are masked images and 5901 are unmasked images. Of the images, 10000 are intended to train the model, 800 images are intended to validated the model.
Download here
This is the open source version of the above mentioned dataset, remade for the purpose of this porject. The copyright details are mentioned in the dataset.

Performance

Judging the performance of the model using loss, accuracy, f1 score, precision and recall as metrics.

API

Website

Contributors

Mentor

  • Dr Chandra Shekar Lakshminarayanan

Demo Video

About


Languages

Language:HTML 57.4%Language:Python 42.6%