0% found this document useful (0 votes)
58 views

Exploring Deep Learning Methods For Face Mask Detection

The global epidemic COVID-19 has brought about a drastic change in the lives of mankind. Health and economic systems were severely impacted by the global epidemic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Exploring Deep Learning Methods For Face Mask Detection

The global epidemic COVID-19 has brought about a drastic change in the lives of mankind. Health and economic systems were severely impacted by the global epidemic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Volume 8, Issue 1, January – 2023 International Journal of Innovative Science and Research Technology

ISSN No:-2456-2165

Exploring Deep Learning Methods for


Face Mask Detection
1
MARITTA STEPHEN, 2USHA K
1,2
NSS College of Engineering, Palakkad, Kerala

Abstract:- The global epidemic COVID-19 has brought surveillance applications where people can be monitored on
about a drastic change in the lives of mankind. Health and wearing a mask for the enforcement of the rules which can be
economic systems were severely impacted by the global implemented by embedding it to mobile applications and
epidemic. The world was under strict restrictions to fight CCTV or other embedded systems.
and control the pandemic. Wearing a face mask is an
essential protective measure to prevent the dissemination Initial screen check for entry are now mandatory at places
of virus in public. The reports suggests that a large like examination halls , offices, malls with regard to the covid
population often ignore or tend to avoid wearing masks restrictions and safety measures. The entry od an individual is
amid strict rules. The project's objective is to devise a face allowed only if the person wears a mask. The work is an useful
mask detector that can determine from visual inputs if an safety precaution and efficient screening and monitoring of
individual is wearing a mask. This work also focuses on security checks at public places and gatherings.
face mask detection of a moving face and can perform real
time face mask detection. Tensor Flow, Keras, OpenCV II. RELATED WORKS
and Scikit-Learn were used to buld the detector along with
Mobilenetv2 for face mask classification SSD (Single Shot There are several studies on approaches for face mask
Multibox detector) with Resnet as the base for face which includes one stage detectors and multi stage detectors
detection. with various classifiers like fast- RCNN, Haar classifiers.
Mohammed Loey in his work [1] developed a novel deep
Keywords:- Deep Learning, Object Detection, Face learning singlr stage detector model based on YOLO-v2 with
Recognition, TensorFlow, Keras, OpenCV, SSD, Mobilenet ResNet-50 for the detection of medical face masks. For feature
extraction, the ResNet-50 deep transfer learning model laid the
I. INTRODUCTION foundation, while a component based on YOLO v2 was
developed for the detection of medical face masks. Unlike
The world is fighting against the largest pandemic never models like RCNN and faster RCNN, which require two or
seen before in the history. Millions of people have been more stages, the YOLO is an one stage detector, allowing
affected by the pandemic and the deeath rates at many parts of detections to be completed in a single step. The proposed
the word are alarmimg. Lockdowns and counter measures had model had poor probability probability or confidence scores
been taken to control the spread of the virus which had great and the confidence of the predicted results was relatively low.
impacts on the economy and people. Unlocking phases are
initiated at different regions and the lives are becoming back Zhang, Jun in his paper [2] proposed a novel detection
to normal but the precautions can never be ignored. The only framework based on the attention mechanism which explicitly
way to outlive the situations is to continue to follow all safety balanced the multiple context features named Context-
measures to control the spread of viruses. Attention R-CNN. The shortcoming of the system is that it
used more hyper parameters and had higher training and
At this phase when the number of instances of covid inference time. The context information was also used by M.
is rising daily and holding our lives in huge risk, the face mask Jiang and X. Fan in their paper [3] which proposed
detector stands out as a step towards monitoring and RetinaMask detector based on the single-stage generic
maintaining a safe and healthy environment. Although the detector named RetinalNet. The RetinaMask also attempted to
virus cannot be completely eradicated, we may take safe and extract the robust feature while taking into account the context
healthy steps to live with it. Face masks are now required to information. RetinaFaceMask combined the high-level
be worn even in locations where lockdown restrictions have semantic data using various feature maps and a feature
been lifted in order to prevent further mass propagation. In this pyramid network (FPN). The detector however had long
regard, the initiative attempted to help the security procedures training time and had complicated post processing.
and systems for detecting whether the face mask is worn by
every individual. B. Qin and D. Li [4] developed a new facemask-wearing
condition identification method by combining image super-
Wearing face mask is now a mandatory measure while resolution and classification networks (SRCNet). However,
stepping out anywhere. Strict measures were taken by the there was a lengthy training process for the system, and it had
government to enforce the rules in this regard to avoid a tendency to fail when the local face was clipped. The study
commuting the virus. A face mask detector arenow used for [5] developed a two-stage method employing hybrid machine

IJISRT23JAN541 www.ijisrt.com 369


Volume 8, Issue 1, January – 2023 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
learning approaches to identify face masks. A broad learning was used to train the face mask classification model. The
system was utilised in the second stage to validate the actual modules involved are discussed below.
facial masks, whereas the first stage was based on the transfer
model of Faster-RCNN and InceptionV2. Small objects and  Data Preprocessing
the recognition of faces hidden by protective clothes and The data preprocessing step prepares the raw data and
medical eyewear presented challenges for this technology. make it suitable for training the model. The data cleaning was
Real time facemask detection was not possible in this method. done manually.The preprocessing module of keras was used
for preprocessing the images before training the
A neural network was all that was put into the one-stage model.Initially the dataset was saved in the directory as two
detector to look find objects. This can be accomplished by folders named with mask and without mask.The aim at the end
predefining some anchor boxes that specify the proportion of was to convert all images into arrays and to obtain the train
object widths to object heights. One-stage detectors improve mask detector file.Two list was created as data and label which
performance in comparison to two-stage detectors to greatly was used to to append image arrays and append with mask or
increase detection speed. In order to achieve the goal, YOLO without mask labels.The categories with mask and without
divided the image up into different cells. Thereafter, they mask was looped into and the images was listed down which
sought to match the anchor boxes to the items in each cell, then followed by joining paths to list corresponding
however this strategy did not perform well for small objects. images.The images was saved as array.The array was
appended to the list.The preprocessed data and labels was
In order to detect faces of various sizes, the multi-scale obtained.
detection strategy introduced in SSD was adopted. This
method conducts detection on a number of feature maps and  Data Augmentation
allows for the detection of faces of various sizes. The proposed Data augmentation on the dataset was performed to meet
system in the project used SSD as the face detection model. the inadequate dataset.Various operations on the existing
dataset was done to expand the dataset.Image datagenerator
III. PROPOSED WORK module of keras was used for data augmentation.The
operations performed on the dataset were rotation, shift,shear
The proposed system Face Mask Detector detects the and flip.
face from the image before determining whether or not the
subject has been wearing a mask. A face and a mask can both  System Design
be detected in real time. If a mask is being worn, it is indicated The face mask detector was developed in two phases.The
by a bounding box drawn over the person's face. Packages like detailed design of the detector is shown in figure 2. Training
Tensor Flow, Keras, OpenCV, and Scikit-Learn were used for and face mask detector deployment are the two phases of the
the facemask detector. With Resnet as the basis architecture face mask detector.
model, the face detection model utilized was SSD (Single Shot
Multibox detector), with the face mask
classifier Mobilenetv2. The mask classification and detection
was performed on various input formats which includes image
input, video input, real time video and images taken from a
real time video. The system architecture is shown in Figure 1

Fig 2: System design

The dimensions of the frame from input images were


acquired, a blob was created from it, and the blob was then put
through the network to obtain the face detections. This allowed
the face mask classifier model to be applied to video streams
and photos. The face detection network used here was SSD
with Resnet as its base architecture. Blob was an image or
Fig 1: System architecture collection of images with some spatial dimensions and it took
an image as an input and performed preprocessing on it by
The Imagenet dataset, which comprises of 3833 images scaling and performing mean subtraction to it. The images
and 1915 images with masks and 1918 images without mask, were normalized by performing mean subtraction which later
on was converted to RGB format.

IJISRT23JAN541 www.ijisrt.com 370


Volume 8, Issue 1, January – 2023 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165

The faces, or a list of faces with their corresponding The model's average accuracy in predicting whether a
locations, and the list of predictions from the face mask person wearing a face masks or not on a validation dataset is
network were obtained for the purpose of face detection. The 99%. The plot in Figure 3 depicts the training loss and
confidence which was the probability associated with the accuracy. The predictions on sample images using the face
detections was extracted by looping over all the detections for mask detector is shown in Figure 4.
video and just on the detection for image. By making sure the
confidence was higher than the minimum confidence, the
weak detections were eliminated. Every detection that fell
below the confidence level was ignored.

The face mask detector detected faces and classified


them with mask and without mask and drew bounding boxes
over them. Retrieved the object's bounding box's x and y
coordinates and made sure the bounding boxes were contained
within the frame's boundaries. Bounding boxes were drawn
over the faces. The ROI was extracted and converted it from
BGR to RGB channel as it was initially preprocessed by
performing mean subtraction. The preprocessing was done
again by ordering, resizing it to 224x224.The faces and
bounding boxes were added to the list .The predictions were Fig 3: Training loss and accuracy
made only when atleast a face was detected otherwise no
predictions were made. The end result was a 2-tuple of the The rectangle red box depicts persons without a mask,
locations of the faces and their associated locations. while the rectangular green box displays detections and
predictions of individuals wearing masks and includes a
The predictions and locations obtained were then used probability score on the upper left. The prediction on images
for face mask detection. Serialized face detector model saved obtained from real time video taken from web camera is shown
in the disk was loaded. The face mask classifier model was in the figure 5.
also loaded from disk along with it. The video stream was
initialised and looped through the frames in order to apply the
model. The threaded video stream's frames were extracted and
resized. Faces were detected in the frame and determined if
they had worn mask or not. The detected face locations were
looped and their associated locations were found which was
followed by unpacking the bounding box and predictions. The
class label and probability were included in the output and the
output frames and images were displayed.

IV. RESULTS

The evaluation metrics accuracy , precision and F1 score Fig 4: Predictions on test images
were used to evaluate the performance of face mask detector.
The classes were balanced, thus the accuracy metric is an
excellent measure to start. Precision provided a measure of the
values that the mask predicted. The classifier could discover
all positive samples using recall, and test accuracy was
determined by the f1 score. The best results in a balanced
dataset were obtained using these evaluation metrics, so that
they were chosen. The classification report for the model is as
given below in Table 1

Table 1: Classification Report


Precision Recall F1 Support
Score
With mask 0.99 0.99 0.99 383
Without 0.99 0.99 0.99 384
mask
Accuracy 0.99 767
Macro avg 0.99 0.99 0.99 767
Weighted 0.99 0.99 0.99 767
avg

IJISRT23JAN541 www.ijisrt.com 371


Volume 8, Issue 1, January – 2023 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
Fig 5: Predictions on real time video. era of the COVID-19 pandemic,’’ Measurement, vol.
167, Jan. 2021, Art. no. 108288
The face mask detector worked well with images and [5]. Comparative Review of YOLO & MobileNet Versions.
video stream inputs. It showed a good accuracy too. The (2021). International Research Journal of Engineering
images and outputs obtained had the face detected and and Technology (IRJET), 7(4), 1–5.
bounding box drawn over it. This could be further improved https://www.irjet.net/archives/V7/i4/IRJET-
upon drawing the bounding boxes over the mouth rather than V7I4970.pdf
the entire face.

V. CONCLUSION

Health experts suggests that the Covid virus cannot be


eliminated entirely from the world. The propaganda preached
is to take safe and healthy precautions to live with it. Wearing
face mask has become mandatory even at places where safety
restrictions are removed so as to avoid further mass
commutation and is taken as precautionary step.The project
aimed to assist the security systems and practices in this
regard.

The proposed system is able to detect face with mask and


without masks successfully using SSD with Resnet as
backbone architecture and Mobilenetv2 as mask classifier.
The transfer learning by using a pretrained model was done
here as to take advantages and weights of the model pretrained
on large GPU and dataset. The Mobilenetv2 was selected
along with face detection model SSD Multibox because of
their ease of deployment in embedded systems and mobile
applications.

The keras application model Mobilenetv2 which had


lesser top1 and top5 accuracy than models like
inception,resnet,VGG16 was selected as their size in hard disk
is very much about four times lesser than other keras
application models so that they requires less runtime memory
and was a best choice for mobile applications SSD used for
face detection makes more predictions and had better coverage
on location, scale, and aspect ratios.

REFERENCES

[1]. Nagrath, Preeti, Rachna Jain, Agam Madan, Rohan


Arora, Piyush Kataria, and Jude Hemanth. "SSDMNV2:
A real time DNN-based face mask detection system
using single shot multibox detector and
MobileNetV2." Sustainable cities and society 66 (2021):
102692.
[2]. M. Loey, G. Manogaran, M. H. N. Taha, and N. E. M.
Khalifa, ‘‘Fighting against COVID-19: A novel deep
learning model based on YOLO-v2 with ResNet-50 for
medical face mask detection,’’ Sustain. Cities Soc., vol.
65, Feb. 2021, Art. no. 102600.
[3]. Zhang, Jun, Feiteng Han, Yutong Chun, and Wang Chen.
"A Novel Detection Framework About Conditions of
Wearing Face Mask for Helping Control the Spread of
COVID-19." IEEE Access 9 (2021): 42975-42984.
[4]. M. Loey, G. Manogaran, M. H. N. Taha, and N. E. M.
Khalifa, ‘‘A hybrid deep transfer learning model with
machine learning methods for face mask detection in the

IJISRT23JAN541 www.ijisrt.com 372

You might also like