Shohrab-Hossain / Face-Mask-Detection

This study confides in Face Mask Detection utilizing Convolutional Neural Network. In this review, a framework will be planned that will recognize facial covering.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Face Mask detection using CNN

Logo



The phrase “novel coronavirus” cites a newly discovered, never-before-seen coronavirus in humans. Coronaviruses are a sort of virus that can cause everything from the common cold to life-threatening diseases such as Severe-Acute-Respiratory-Syndrome and Middle-East-Respiratory-Syndrome. COVID-19 is an inhaling illness that causes severe pneumonia in those who are infected.

Wearing a mask is required in several nations during this COVID-19 epidemic, and it does cut death rates. Wearing a mask is essential inasmuch as the vaccination is not widely used and does not fully protect everyone. Preventing the transmission of infection is critical. Authorities require a method of monitoring public spaces such as subway stations and shopping malls. As a result, masked and unmasked face recognition is required. Using a combination of video analysis, image classification, object tracking, and object identification, a system like this can recognize persons wearing face masks in photos and videos. Face mask recognition may be done with a variety of machine learning tools. Deep convolutional neural networks have recently been successfully used to recognise face masks.



Topics of this study are listed below:

  1. Face Detection
  2. Face Mask Recognition
  3. Introduction to Research Planning
  4. Design of CNN
  5. Result Analysis
  6. Conclusion



Face Detection

In the field of computer vision, face perception is the most common study topic.It is a computer technology that predicts human faces in digital photos and is utilized in a range of applications. Face detection is one of the hottest topics in technology right now. The primary and preliminary stage in the study of face prediction is the localization of human faces. For instance, video surveillance in the home. Face localization is the process of extracting face features utilizing a pattern recognition algorithm. Face detection methods that are now available are as follows:

  • Haar Cascade(Haarcascade_frontalface_default.xml)
  • Local Binary Patterns Histograms(createLBPHFaceRecognizer())
  • Fisher Faces (createFisherFaceRecognizer())
  • Eigenfaces (createEigenFaceRecognizer())

Haar Cascade Features


Figure 01. Haar Cascade Features




Face Mask Recognition

Nowadays, one of the most essential technologies is face mask detection. For this, a variety of machine learning tools can be used. For this type of Detection, Deep Learning is the ideal option. Following the detection of a face in an image or video, a deep learning network, such as a Convolutional Neural Network, can be employed for detection. When compared to other machine learning technologies, CNN has a few advantages in image processing.


Face Detection


Figure 02. Face Mask Detection




Introduction to Research Planning

This study confides in Face Mask Detection utilizing Convolutional Neural Network. In this review, a framework will be planned that will recognize facial covering. To prepare the model, a dataset of pictures will be gathered from an online cloud repository. The gathered raw dataset will be processed. The faces of people will be cropped, and from the annotation XML document, the labels for each cropped face will be stored in a data frame. Utilizing the cropped pictures and the labels, the CNN model will be trained. Subsequent to preparation the model will be utilized to distinguish facial covering. A sample picture will be imported from the dataset. The face of the people will be identified by utilizing a face classifier. Then, at that point, these faces will be utilized to anticipate facial covering by the trained CNN model. Contingent upon the expectation, the class will be anticipated: with-mask, without-mask, or incorrectly-worn-mask.



Methodology

This study aims to design a CNN structure for Face Mask Detection. The methodology of this exploration is displayed in Figure 06. There are three stages in this exploration: Preprocess, Training, and Detection.


Methodology


Figure 03. Methodology




Preprocessing

In preprocessing stage, the raw dataset will be processed first. There are pictures in this dataset and an annotation XML document with attributes of this large number of pictures. The annotation document will be analyzed, and the coordinates of the faces will be extracted. Utilizing these coordinates, the faces from each picture will be cropped and stored locally.


Preprocessing


Figure 04. Preprocessing Flow Chart




Training

In the training stage, the labels are separated from the annotation file. The annotation document contains data of the labels of each face: with-mask, without-mask, incorrectly-worn-cover. After label extraction, a data frame will be created containing the cropped faces and the label for each face. A CNN model is designed then, at that point. With the generated data frame, the CNN model will be trained for facial covering identification.


Training


Figure 05. Training Flow Chart




Detection

In the detection stage, a sample picture will be imported from the dataset. Then the faces in the picture will be distinguished by utilizing a face classifier. Haar Cascade Face Classifier will be utilized for this arrangement. Each recognized face of the picture will be utilized to anticipate by the prepared CNN model. In light of the forecast, the class will be identified for facial covering recognition.


Detection


Figure 06. Detection Flow Chart




Design of CNN

CNN, like other neural networks, has input and output layers. There are many hidden layers between these two tiers. There are a classification layer and some hidden layers for extracting features. Two Convolution Layers are followed by a Max Pooling Layer in the planned CNN model. Then there are two more Convolution layers and a Max pooling layer. Then there’s a Dense Layer and a Flatten Layer. The output class of the Dense Layer is three, which is the same as the number of labels in the dataset.


Design of CNN


Figure 07. Design of CNN



Details about each of these layers can be found here.




Result Analysis

The training machine contains 8.00 GB of RAM, a 64-bit operating system, and an Intel(R) Core(TM) i7-4500U CPU with speeds of 2.40 GHz and 1.80 GHz.



Result plot


Figure 08. Result of Training



When tested with test data, the trained model had an accuracy of 92.00 %. The model’s performance is depicted in Figure 09.


Model Performance


Figure 09. Model Performance



Some of the predicted images are shown below,


Detection 01


Detection 02


Detection 04


Figure 10. Predicted Images




Conclusion

Face mask detection is accomplished using a CNN in this study. Python was utilized to implement the model in the study. This study makes use of NumPy, Pandas, OpenCV, and TensorFlow. The CNN model is trained using cropped faces from training photos, and the trained model subsequently accurately predicted single and multi-facial face masks. When tested with validation data, the trained model had a high prediction accuracy.





Important Links

  1. Documentation of Convolution Neural Network : Link
  2. Cloud repository of Face Mask Dataset : Link



About

This study confides in Face Mask Detection utilizing Convolutional Neural Network. In this review, a framework will be planned that will recognize facial covering.


Languages

Language:Jupyter Notebook 100.0%