A Facemask Detector Using Machine Learni
A Facemask Detector Using Machine Learni
A Facemask Detector Using Machine Learni
Computer
er Engineering and Applications,
1,2
Department of computer science and IT, Student, Amity University Jharkhand
ABSTRACT
Changes in the lifestyle of everyone around the world. In those changes wearing a mask has been
very vital to every individual. Detection of people who are not wearing masks is a challenge due to
Outbreak of the Coronavirus pandemic has created various the large number of populations. This
project can be used in schools, hospitals, banks, airports, and etc. as a digitalized scanning tool. The
technique of detecting people’s faces and segregating them into two clas
classes
ses namely the people with
masks and people without masks is done with the help of image processing and deep learning. With
the help of this project, a person who is intended to monitor the people can be seated in a remote
area and still can monitor efficiently
ently and give instructions accordingly. Various libraries of python
such as OpenCV, Tensorflow and Keras. In Deep Learning Convolution Neural Networks is a class
Deep Neural Networks which is used to train the models used for this project.
1
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
INTRODUCTION
The trend of porting face mask publically is rising because of the Covid-19 epidemic
everywhere in the world. Because Covid-19 people wont to wear mask to shield their health
from air pollution. Whereas other are self-conscious concerning their looks, they hide their
emotions from the general public by activity their faces. Somebody treated the wearing face
masks works on hindering Covid-19 transmission. Covid-19 is that the last epidemic virus that
hit the human health within the last century. In 2020, the fast spreading of Covid-19 has forced
the who to declare Covid-19 as international pandemic. Quite 5 million cases were infected by
Covid-19 in not up to half dozen month across 188 countries. The virus spreads through shut
contact and in packed and overcrowded areas. The corona virus epidemic has given rise to a
unprecedented degree of worldwide scientific cooperation. Computer science supported
machine learning and deep learning will facilitate to fight Covid-19 in several ways. Machine
learning a valuate huge quantities of knowledge to forecast the distribution of Covid-19, to
function early warning mechanism for potential pandemics, and classify vulnerable population.
Folks are forced by laws to wear face masks publically many countries. These rules and law we
have a tendency yore developed as associate degree action to the exponential growth in cases an
deaths in several areas.
However, the method observation massive teams of individuals is changing into a lot of
difficult. The monitoring process involves the finding of anyone who isn’t sporting a face mask.
Here we introduce a mask face detection model that’s supported machine learning and image
process techniques. The planned model may be detect the mask with image and real time
detection people wearing mask or not wearing a mask. The model is integration between deep
learning and classical machine learning techniques with OvenCV, Tensor Flow and Keras. We
have a tendency to introduced a comparison between them to seek out the foremost appropriate
algorithm program that achieved the very best accuracy and consumed the smallest amount time
within the method of coaching and detection.
LITERATURE SURVEY
Generally, most of the projects specialize in face construction identity recognition when
wearing mask. During this projects, the focus is on recognizing the people that wearing mask, or
2
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
not help in decreasing the transmission and spreading of covid-19. The scientist has proven that
wearing a mask help in minimizing the spreading rate of Covid-19.
In [1], the authors developed a face mask wearing condition identification method. They were
ready to classify three categories of face mask-wearing. The categories are face mask- wearing,
incorrect face mask-wearing and no face mask-wearing. Saber et al [2], have applied the
principal component analysis on masked and unmasked face recognition to acknowledge the
person. Also, PCA was utilized in[3]. The author proposed a way that’s used for removing
glasses from human frontal faces. In[4], the authors used the YOLOv3 algorithm for face
detection. YOLOv3 uses Darknet-53 because the backbone. Nizam et al [5] proposed a
completely unique GAN-based network, which will automatically remove mask covering the
face area and regenerate the image by building the missing hole. In [6], the authors presented a
system for detecting the presence or absence of a compulsory medical mask within the
OR. The general is to attenuate the false positive face detection as possible without missing
mask detection so as to trigger alarms just for medical staff who don't wear a surgical
mask.Shaik et al [7] used deep learning real-time face emotion classification and recognition.
They used VGG-16 to classify seven countenance.
Under the present Covid-19 lock-in time, this technique is effective in preventing spread in may
use cases. Here are some use cases which will benefit form system.
Airports: the proposed system could also be vital find travelers at airports. there's no mask. The
traveler’s data are often captured as a video within the system at the doorway . Any passenger
who finds no mask will alert the airport authorities send in order that they can act quickly. [13]
Hospital: the proposed system are often integrated with CCTV cameras, and therefore the data
are often manage to ascertain if its employees are wearing masks. If you discover some doctors .
If the aren't wearing a mask, they're going to receive a reminder to wear a mask. [22]
Office: The proposed system can help to take care of safety standards to stop . The spread of
covid-19 or any such airborne disease. If some employees aren't wearing masks, they're going to
receive reminders to wear mask. [22]
3
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
The choice of the system must be supported the simplest performance. So, I'm using the
simplest system performance indicators in order that you'll large –scale implementation.
For MobileNetV2 classifier, ADAM optimizer has been applied to see performance:
ADAM[13]: Adam, a stochastic optimization algorithm supported step the target function is
predicated on an adaptive estimation of low-order moments. this manner it's computationally
efficient and may be executed almost without memory. It’s the diagonal of the gradient is
rescaled unchanged, which is extremely suitable for the subsequent problems large in terms of
knowledge and/or parameters. Hyper parameters are intuitive explain that they typically don't
require much adjustment. The empirical results show that Adam it works well in practice and
may be compared with other stochastic optimization method.
RELATED WORK
Machine Learning
4
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
Supervised learning its supervised learning we have several data points or samples described
using predictive variables or features and the target variable our data represented in table
structure. Game supervised learning is build a model its able to predict the target variable.
Unsupervised learning is a machine learning task the uncovering hidden patterns from
unlabeled data.
Computer Vision
It is a field that include processing analyzing and understanding image in general high
dimensional data from the real world in order to produce numerical and symbolic information or
it is a technology of science and machine that see it obtain information from images.
Deep Learning
Deep learning is a powerful set of techniques for learning using neural network. Neural network
are beautiful biologically inspired programing paradigm which enables a computer to learn from
data. These are learning algorithms
Open CV
OpenCV (Open Source Computer Vision Library) is a collection of algorithms for computer
vision. it basics focus on real time image processing it is free for commercial and research use
under a BSD license..
TensorFlow
TensorFlow is a mathematical computation library for training and building your machine
learning and deep learning model with a simple to use high level APIs.
Keras
5
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
Keras is a neural network API. It is library written specifically in python. Also, It works with
other libraries and packages such as tensorflow which makes deep learning easier. Keras was
developed to allow for quick experimentation and for fast prototyping.
CNN
Convolutional Neural Network are designed to process data through multiple layers of arrays.
This type of neural networks is used in application like image recognition of face recognition.
The primary difference between CNN and other ordinary neural network is that CNN takes
input as a two dimensional array and operates directly on the images rather than focusing on
feature extraction which other neural network focus on.
The dominant approach of CNN includes solutions for problems of recognition. Top companies
like google and facebook have invested in research and developments towards recognition
projects to get activites done with greater speed.
I am using different architecture and models of ANN were used for face mask detection. ANN
can be used in face mask detection because these models can simulate the way neurons work in
human brain. I comparison between different neural network for face mask recognition system
and lastly we use those model which have better accuracy.
I am presented face mask detection system based on a RCNN that examine small windows of an
image to check each window contain face with or without mask. First, a preprocessing step,
adapted from, is applied to window of the image. Then window is passed through the neural
6
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
network, which decides whether the window contain face with or without mask. They used the
two training dataset of image. In first dataset with mask images collected by me consist of total
800 images. The second dataset without mask consist of 750 images, The recognition face with
mask and without mask equal to 80% accuracy rate.
I am using PCA with class specific linear projection to detect or recognized face with or without
mask in a real time video stream. The system steps to search for face with or without mask in an
image:
In this planned method, the mask detection model is constructed victimization the successive
API of the keras, library. this permits us to make the new layers for our model step by step. the
assorted layers used for our CNN model is represented below.The 1st layer is that the Conv2D
layer with one hundred filters and therefore the filter size or the kernel size of 3X3. During this
first step, the activation operate used is the ‘ReLu’. This ReLu function stands for corrected
linear measure which is able to output the input directly if is positive, otherwise, it'll output
zero. The input size is also initialized as 150X150X3 for all the photographs to be trained and
tested victimization this modelIn the second layer, the MaxPooling2D is employed with the
pool size of 2X2The next layer is once more a Conv2D layer with another one hundred filters of
constant filter size 3X3 and {also the} activation operate used is that the ‘ReLu’. This Conv2D
layer is followed by a MaxPooling3=2D layer with pool size 2X2.
In consecutive step, we have a tendency to use the Flatten () layer to flatten all the layers into
one 1D layer. After the Flatten layer, we use the Dropout (0.5) layer to forestall the model from
7
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
overfitting.Finally, towards the end, we have a tendency to use the Dense layer with fifty units
and therefore the activation operate as ‘ReLu’.
The last layer of our model are going to be another Dense Layer, with solely 2 units and the
activation function used will be the ‘Softmax’ function. The softmax function outputs a vector
which is able to represent the chance distributions of every of the input units. Here, two input
units are used. The softmax function will output a vector with two probability distribution value.
The proposed FNN for the face mask detection. A FNN approach to reduce the computational
time for locating human faces with or without mask. Each image is divided into small sub
images and then each one is tested separately using a fast ANN. The experimental result of
comparison with conventional neural network showed that high speed achieved when applying
FNN.
1 RCNN 90.45
3 CNN 95.22
4 FNN 94
8
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
After the comparison the two best methodlogy is CNN and PCA with AAN both recognition
rate areapproxmitely same then I am using for the CNN for the face mask detection mode.
DATA COLLECTION
The dataset pictures for covert and unmasked faces were collected from images dataset offered
within the public domain the masked images were obtained from the factitious generated by me
through the picture redaction tool and few from collected from the pu
public
blic domain. Within the
data set the onsite of 800 with masked face and 750 are while not masked face. The data set is
collected for the training the faask
ask detection model.
9
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
METHODLOGY
Face detection
The downside of face mask detection is all regarding face detection. However, before face mask
detection is possible, on should be able to faithfully notice a face and its landmarks. This can be
basically a segmentation problem and in sensible system, most of the trouble goes into finding
this task. After all the particular detection supported options extracted from these facial
landmarks is barely a minor step
10
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
The proposed system focuses on how to identify a person wearing a mask on the image/video
stream. Help with computer vision and deep learning algorithm by using OpenCV, tesnsorflow,
Keras library.
Method:
11
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
In the first step, let us visualize the total number of images in the dataset in these two categories.
We can see that there are 800 images in the “Yes” category and 750 images in the “No”
category.
Table 2
In the next step, we expand the data set to include a larger number of images for training. In this
step of data expansion, we rotate and flip each image in the data set. We see that after data
expansion, we have total 2851 images of which the “yes” category contains 1430 images, and
the “no” category contains 1421 images.
In this step, we divide the data into a training set, and the training set will contain the images on
which the CNN model will be trained and test set and the images on which the model will be
tested.
In this case, we use split_size =0.8, which means that 80% of the total images will enter the
training set, and the remaining 20% of the images will enter the test set.
Training No 1121
Test No 300
Table 3
After segmentation, we see that the required image percentage has been allocated to the training
set and test set as described above.
In the next step, we will use Conv2D, MaxPooling2D, Flatten, Dropout, and dense to build a
sequential CNN model. In the last dense layer, we use the “ soft ax ” function to output vector
that gives the probability of each of the two categories.
13
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
Here, we use
se “ADAM” optimizer and “binary crossentropy” as our loss function because there
are only two types. In addition, you can even use MobileNetV2 to get better accuracy.
After setting up the model let us create”train generator” and “validation_generator” to make it
fit our model in the next step. We see a total of 2250 images in the training set and a total of 551
images in the test set.
This is the main step in which we put Images into the training set and test set to use the
sequence model built by the keras library. I have trained the model for 20 epochs. However, we
can train more epochs to obtain higher accuracy, so as to avoid overfitting.
history = model.fit_generator(train_generator,
epochs=20,
validation_data=validation_generator,
callbacks=[checkpoint])>>Epoch 20/20
14
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
After building the model, we label the results with two probabilities.[“0” is “without mask”, “1”
is “with_mask”]. I also set the color of the bounding rectangle using RGB values. [“RED”
stands for “without mask” “GREEN” stands for “with mask”’].
labels_dict={0:'without_mask',1:'with_mask'}
color_dict={0:(0,0,255),1:(0,255,0)}.
From now on, we plan to use it to detect whether we are wearing a mask through the pc’s
webcam. For this, first of all, we need to implement face detection
In the last step, we use the OvenCV library to run an infinite loop to use our webcam, where the
cascade classifier is used to detect faces. The code webcam =cv2.videoCapture (0) indicates the
usage of the webcam. The model will predict the likelihood of each of the two categories
[without mask, with mask]). Based on a higher probability, tags will be selected and displayed
around our face.
15
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
FLOW DIAGRAM:
MobileNetV2
16
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
3. Dropout Layer
4. Linear layer with Softmax activation function with the results of 2 values
17
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
The final layer softmax function gives two result each probability represe
represent
nt the classification of
the “mask” or “non-masked”.
RESULT
Experimental Result
The experimental result of system performance are evaluated with the MobileNetV2
MobileNetV classifier
and ADAM optimize
Figure 11: compilation screen for training script of face mask detection.
18
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
FINAL RESULT
Combining all the elements of our architecture, we tend to so get correct mask observation
system. MobileNetV2 classifier employed in this system. The resultant system performance and
has the potential to detect face mask in image with multiple face over a large vary angles.
19
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Comput
Computer
er Engineering and Applications,
Figure 14: Detect face with mask from imageFig 15: Detect face without mask from image
Figure 16: Detect face with mask or without mask in real time video stream
CONCLUSION
As the technology are blooming with emerging trends the availability so we have novel face
mask detector which can possibly contribute to public health care department. The architecture
consist of MobileNetV2 classifier and ADAM optimizer as the back bone it can be used for high
and low computation scenarios. The our face mask detection is trained on CNN model and we
are used OvenCV, Tensor Flow , Keras and python to detect whether person is wearing a mask
or not . The model were tested with image and real
real- time video stream. The accuracy of model
is achieved and, the optimization of the model is continuous process. This specific model could
be used as use case of edge analytics
20
AMRITT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
FUTURE SCOPE
The current ongoing system is gracing with MobileNetV2 classifier one of the best system
which would be implemented along with the interface of alarm and alerting system in future
generation. This system will be integrated with the system implementing social distancing that
would make it a complete system which can bring a dramatic impact on the spread of. The new
world will be well being of high demand of mask as faceless future and that will be a big
security concern. Expertise say, CNN that using face mask proves to be the best solution to
mitigate the spread of air borne virus like corona, but as a big security concern headed to
challenge the nation as it would create a massive opportunity for people who cover their faces
for nefarious reason. And also experts say the mass no of mask wearing in could complicate in
crime investigation in the coming days, as facial recognition is an important part in tracking of
the criminals. When the pandemic covid-19 getting over, then this system comes into play for
chemical factories, bank, glass factories etc. If a person enters the bank while wearing a mask he
would be not allowed to enter and also if the person does not wear masks in glass factories
chemical factories and etc. then the person would not be allowed to enter to the industry. A
mind concept of human being have been proved out to be very good at recognizing familiar
faces and facial recognizing familiar faces and facial recognition algorithms are getting better in
identifying pattern. So thus this challenge would create a scope to new face detection algorithms
which can identify aces which are covered with greater accuracies and precisions.
REFERENCE
[1] B. QIN and D. Li, Identifying facemask-wearing condition using image super-resolution
with classification network to prevent COVID-19, May 2020, doi: 10.21203/rs.3.rs-
28668/v1.
[2] M.S. Ejaz, M.R. Islam, M. Sifatullah, A. SarkerImplementation of principal component
analysis on masked and non-masked face recognition 2019 1st International Conference on
Advances in Science, Engineering and Robotics Technology (ICASERT) (2019),
pp. 15, 10.1109/ICASERT.2019.8934543
21
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
[3] Jeong-Seon Park, You Hwa Oh, Sang ChulAhn, and Seong-Whan Lee, Glasses removal
from facial image using recursive error compensation, IEEE Trans. Pattern Anal. Mach.
Intell. 27 (5) (2005) 805–811, doi: 10.1109/TPAMI.2005.103.
[4] C. Li, R. Wang, J. Li, L. Fei, Face detection based on YOLOv3, in:: Recent Trends in
Intelligent Computing, Communication and Devices, Singapore, 2020, pp. 277–284, doi:
10.1007/978-981-13-9406-5_34.
[5] N. Ud Din, K. Javed, S. Bae, J. YiA novel GAN-based network for unmasking of masked
face IEEE Access, 8 (2020), pp. 4427644287, 10.1109/ACCESS.2020.2977386
[6] A. Nieto-Rodríguez, M. Mucientes, V.M. BreaSystem for medical mask detection in the
operating room through facial attributes Pattern Recogn. Image Anal. Cham (2015),
pp. 138-145, 10.1007/978-3-319-19390-8_16
[7] S. A. Hussain, A.S.A.A. Balushi, A real time face emotion classification and recognition
using deep learning model, J. Phys.: Conf. Ser. 1432 (2020) 012087, doi: 10.1088/1742-
6596/1432/1/012087.
[9] Xin, M., Wang, Y. Research on image classification model based on deep convolution
neural network. J Image Video Proc. 2019, 40 (2019).
[10] Sultana, F., A. Sufian, and P. Dutta. "A review of object detection models based on
convolutional neural network." arXiv preprint arXiv:1905.01614 (2019).
[11] X. Jia, "Image recognition method based on deep learning," 2017 29th Chinese Control
And Decision Conference (CCDC), Chongqing, 2017, pp. 4730-4735, doi:
10.1109/CCDC.2017.7979332.
22
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
[12] MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications -
Andrew G. Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias
Weyand, Marco Andreetto, Hartwig Adam.
[13] Deep Residual Learning for Image Recognition, He, Kaiming, Xiangyu Zhang,
Shaoqing Ren, and Jian Sun. arXiv:1512.03385,2015
[14] Image Classification Using Convolutional Neural Networks DeepikaJaswal,
Sowmya.V, K.P.Soman
[15] https://edition.cnn.com/2020/05/10/world/face-masks-security-intl-gbr/index.html
[16] https://www.theverge.com/2017/9/6/16254476/facial-recognition-masks-diguisesai
International Journal of Advanced Science and Technology Vol. 29, No. 11s, (2020), pp.
3074-3082 ISSN: 2005-4238 IJAST 3082 Copyright ⓒ 2020 SERSC
[17] https://www.bbc.com/future/article/20200504-coronavirus-what-is-the-best-kindof-
face-mask
[18] https://www.sfcdcp.org/communicable-disease/healthy-habits/how-to-put-on-
andremove-a-face-mask/
[19] https://www.pyimagesearch.com/2020/05/04/covid-19-face-mask-detector-withopencv-
keras-tensorflow-and-deep- learning/
[20] https://www.leewayhertz.com/face-mask-detection-system/
[21] https://ai.googleblog.com/2018/04/mobilenetv2-next-generation-of-on.html
[22] https://thehill.com/opinion/cybersecurity/498113-facial-recognition-the-otherreason-
we-may-need-a-face-mask
[23] https://www.cnet.com/news/n95-like-mask-concept-would-allow-you-unlockphone-
face-id/
[24] https://www.wired.com/story/algorithms-recognize-masked-face/
[25] https://www.reuters.com/article/us-health-coronavirus-facialrecognition/even-mask-
wearers-can-be-idd-china-facial- recognition-firm-saysidUSKBN20W0WL/
[26] https://analyticsindiamag.com/why-googles-mobilenetv2-is-a-revolutionarynext-gen-
on-device-computer-vision-network/
23
AMRIT KUMAR BHADANI ANURAG SINHA
International Journal of Computer Engineering and Applications,
[27] https://towardsdatascience.com/covid-19-face-mask-detection-using-tensorflow-and-
opencv-702dd833515b/
[28] https://towardsdatascience.com/data-visualization-for-machine-learning-and-data-
science-a45178970be7/
[29] https://medium.com/@harshilp/real-time-face-mask-detector-with-opencv-keras-
tensorflow-and-deep-learning-d0744fe048c6/
[30] www.tensorflow.org
[31] Python machine learning (Author: Sebastian Raschka)
[32] Deep Learning (Authors: RajalingappaaShanmugamani).
[33] Deep Learning for computer vison: Expert Techniques to Train Advanced Neural
Networks Using TensorFlow and Keras(author: RajalingappaaShanmugamani).
[34] https://www.researchgate.net/publication/282273241
[35] https://www.researchgate.net/publication/282273241/
24
AMRIT KUMAR BHADANI ANURAG SINHA