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

Real Time Face Mask DetectorUsing Machine Learning

1) The document describes a machine learning model for real-time face mask detection using TensorFlow, Keras, OpenCV and Scikit-learn. 2) The model uses two datasets containing over 3,800 images total - one with people wearing face masks and one without. 3) The proposed approach uses a cascade classifier and pre-trained CNN with convolutional and dense layers to detect faces and classify them as masked or unmasked in real-time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Real Time Face Mask DetectorUsing Machine Learning

1) The document describes a machine learning model for real-time face mask detection using TensorFlow, Keras, OpenCV and Scikit-learn. 2) The model uses two datasets containing over 3,800 images total - one with people wearing face masks and one without. 3) The proposed approach uses a cascade classifier and pre-trained CNN with convolutional and dense layers to detect faces and classify them as masked or unmasked in real-time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Volume 7, Issue 6, June – 2022 International Journal of Innovative Science and Research Technology

ISSN No:-2456-2165

Real Time Face Mask DetectorUsing Machine Learning


KV Shalini [1] Ruthvik R, Prerana R, Suhas KR, Suhas S Student
Asst. Professor Department of Computer Science Department of Computer Science and engineering KSSEM
KSSEM, Bangalore, India Bangalore, India

Abstract: - The current situation of COVID needs an The hassle is without delay linked to general detection for
efficient way to check masked and non-masked faces. The detecting the training of items. Face identification categorically
main objective of the project is to build this system at deals with distinguishing an entity of specificgro us of a.e.,
entrances of public spaces like organizations, educational Face. It has numerous forms of applications, together with self-
institutions, temples where there is a high probability of using, education, remarkable vision, and so on. this newsletter
spread of COVID. WHO (World health organization) offers a simplified technique for serving the above goal through
reported that covering face and nose with masks during the the use of primary gadget learning (ML) applications along with
work reduces the risk of spread. The process works likes TensorFlow, Keras, OpenCV and Scikit-learn.
While entering the public place everybody should scan their
face and then move forward making sure they are wearing II. RELATED WORK
a mask or not. If anyone is without covering their face with
mask, sound alert will be given. As all the organizations are In detection of face mask challenge, a person face is
opening. The number of Covid cases are still getting to identified from an picture that carries extra attributes in it.
increase in the country. If everybody maintains the safety consistent with, facial detection research requires reputation of
measures, then we can end this pandemic all together. expression, face tracking, and estimation of pose. With an
Hence to check whether the people wear Face masks while image alone, the challenging mission is to discover the folks
coming to any public spaces we ensure this paper will help face from the photograph. There may be more issue in detecting
in detecting it. the face because there are unique faces of various sizes, shapes,
and colorings and many others. And they are no longer
Keywords:- COVID, Keras, OpenCV, Safety measures, invariable. It’s a hard task for blurred or grimy photos troubling
Facemask Dataset, Without Facemask Dataset. via some other various things but not tough camera, and so
forth. The people assume detection of face include fundamental
I. INTRODUCTION demanding situations:
1) Datasets of sizably voluminous is unavailable which has each
Attractive course of action to prevent COVID pandemic masked and non-masked faces.
need excessive awareness to reduce harmful impact of network 2) removal of facial expression inside the protected area.
health and global economy, with complete of boundary that's
unfolded. in the no need of antibacterial and finite clinical Multiple misplaced expressions may be recovered, and the
resources, many motion where pronounced by way of WHO to ascendancy facial cues can be significantly alleviated. there's
govern the pandemic instances and prevent the use of dangerous strict constrain with recognize to the scale of inputting picture
medical resources. protecting nostril and mouth with the face which changed into said by way of CNNs in pc vision. The
mask is considered one of the medicine loose remedies that's common steps reform the picture before fixing them into the
used to reduce the initial resources of excessive acute network to recover from the drawback. To understand the
respiratory syndrome coronavirus 2 drops throwed out by using picture effectively with respect to masked and non-masked
an affected character. nonetheless, of discus is on on clinical faces is a challenging undertaking. The proposed mission need
assets and multiplicity in sporting the face mask, each and all to additionally stumble on a face along side a mask in motion
nations are ordering to cover their nose and mouth in public to carry out the surveillance activities.
location compulsorily. To provide closer to community health,
this module focuses to construct a relatively précised and III. DATASET
concurrent method that can flawlessly discover the man or
woman without face masks in public spaces and subsequently, Two datasets have been used for experimenting the
imposing to wear mask. Face masks detection refers to stumble current method. Dataset 1 c o n s i s t s of 1915 images, which
on whether or not a person is sporting a mask or now not. Face consists of people wearing face masks. Fig. 1 shows people
mask detection is a method of determining masks and Non wearing facemask.
mask faces.

IJISRT22JUN1511 www.ijisrt.com 1056


Volume 7, Issue 6, June – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
B. Keras
Keras is used for developing deep models which can be
productized on smartphones. Keras is also used for disbursed
training of deep getting to know models. Keras is used by
organizations along with Netflix, Yelp, Uber, and so forth. in
data processing, it helps to collect the general version.

C. OpenCV
OpenCV (Open-supply laptop vision Library) is an open-
supply pc imaginative and prescient and gadget learning
software program library. OpenCV was constructed to provide
a not unusual infrastructure for pc imaginative and prescient
Fig.1 Persons with mask dataset
applications and to boost up using machine notion within the
business products. OpenCV is used in wide variety of utility
Dataset 2 consists of 1918 images which consists of people not
which includes street view picture sewing, computerized
wearing face mask. In fig. 2 shows people not wearing face masks.
inspection and surveillance, robotic and driving force-much
less car navigation and manage, clinical photograph evaluation,
Video/image seek and retrieval, films - 3-d shape from
movement, Interactive art installations.

V. THE SUGGESTED METHOD

The Proposed approach includes of a cascade classifier


and a pre- organized CNN which incorporates second
convolution layers associated to layers of thick neurons. The
confront veil place incorporates of the taking after calculations:

A. Data Preprocessing
Data preprocessing, a aspect of records practice, describes
any type of processing completed on uncooked records to put
together it for some other information processing system. It has
historically been an critical preliminary step for the data mining
system. The recommended method involves the image and
video facts the use of NumPy and OpenCV.

Fig. 2. Persons without masks dataset B. Data Visualization


Data preprocessing, a component of data preparation,
IV. INTEGRATED PACKAGES describes any type of processing performed on raw data to
prepare it for another data processing procedure. It has
A. TensorFlow traditionally been an important preliminary step for the data
A terminal for expressing gadget trendy algorithms, is mining process.
make use for executing device ultra-modern structures into
production over a package deal today's regions latest computer The total number of images in the dataset is visualized in
science, along with video detection, time collection, textual both categories–‘with mask’ and ‘without mask’. The
content-based totally application. TensorFlow is a symbolic statement categories=os. listdir (data path) categorizes the list
math library used for neural networks and is best suited for of directories in the specified data path. The variable categories
dataflow programming throughout more than a few duties. It now look like: [‘with mask’, ‘without mask’] Then to find the
offers more than one abstraction levels for constructing and number of labels, we need to distinguish those categories using
education fashions. It’s an cease-to-give up open-source labels= [I for I in range (Len(categories))]. It sets the labels
platform for device gaining knowledge statemodern. It has a as: [0, 1]
complete, bendy ecosystem modern-day gear, libraries and
network sources that shall we researchers push the Now, each category is mapped to its respective label using
49a2d564f1275e1c4e633abc331547db in ML and builders label dict=dict (zip (categories, labels)) which at first returns an
easily build and set up ML powered packages. iteratorof tuples in the form of zip object where theitem in each
passed iterator is paired together consequently. The mapped
variable label dict looks like: {‘with mask’: 0, ‘without mask’:
1}

IJISRT22JUN1511 www.ijisrt.com 1057


Volume 7, Issue 6, June – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
C. Conversion of RGB image to gray image returns the dimensions of the statistics array from index
The primary purpose why grayscale representations are
often used for extracting descriptors in preference to working 1. Default padding is “valid” wherein the spatial
on color images directly is that grayscale simplifies the set of dimensions are sanctioned to truncate, and the enter quantity is
rules and reduces computational requirements. Grayscale only non-0 padded. The activation parameter to the Conv2D
includes luminance (brightness) statistics and no coloration magnificence is ready as “relu”. It represents an approximately
statistics; that is why maximum luminance is white and 0 linear function that possesses all of the assets of linear models
luminance is black; everything in among is a shade of gray. that that can without difficulty be optimized with gradient-descent
is why grayscale pix comprise handiest sunglasses of grey and methods. thinking about the performance and generalization in
no color. Grayscale is also known as achromatic. deep gaining knowledge of, it's miles higher compared to
different activation functions. Max Pooling is used to reduce the
spatial dimensions of the output extent. Pool size is ready to 3
x three, and the ensuing output has a form (wide variety of rows
or columns) of: form of output = (enter shape - pool size+ 1) /
strides), in which strides have default price (1,1).

As shown in fig, four, the second one Convolution layer


has one hundred filters and Kernel length is ready to a few x 3.
Fig. 3. RGB image to grey scale image conversion it's far followed by means of Relu and MaxPooling layers. To
insert the facts into CNN, the long vector of enter is surpassed
We use the function cv2.cvtColor(enter image, flag) for via a Flatten layer which transforms matrix of features right into
changing the color space. right here flag determines the form of a vector that can be fed into a totally linked neural network
conversion. In this case, the flag cv2.color BGR2GRAY is used classifier. To reduce overfitting a Dropout layer with a 50%
for grey conversion. Deep CNNs require a certain-size input danger of placing inputs to 0 is introduced to the version. Then
picture. consequently, we need a certain common size for all of a Dense layer of sixty four neurons with a Relu activation
the photographs in the dataset. the grey scale photo is resized characteristic is added. The very last layer (Dense) with outputs
into a hundred x 100 the use of cv2.resize(). for 2 instructions makes use of the SoftMax activation
characteristic.
D. Image Reshaping
maximum convolutional neural networks are designed in
a way so as to handiest receive pictures of a set length. This
creates several demanding situations throughout data
acquisition and version deployment. The commonplace
exercise to overcome this limitation is to reshape the input pics
in order that they can be fed into the networks. The pics are
normalized to converge the pixel range among zero and 1. Then
they may be transformed to four di- mensional arrays the use of
records=np. reshape (statistics, (facts. shape [0], img size, img
size,1)) where 1 indicates the Grayscale photo. As, the very last
layer of the neural community has 2 outputs – with masks and
without mask i.e., it has specific representation, the data is
converted to express labels.
Fig. 4. Convolutional Neural Network architecture
E. Training of Model
The studying manner needs to be configured first with the
a) building the model using CNN structure: CNN has turn out assemble approach. here “Adam” optimizer is used. express
to be ascendant in miscellaneous pc vision tasks. The present move entropy which is also known as multiclass log loss is used
day method uses Sequential CNN. as a loss function (the goal that the model tries to minimize). as
The first Convolution layer is followed by Rectified the hassle is a classification problem, metrics is set to
Linear Unit (ReLU) and MaxPooling layers. The Convolution “accuracy”.
layer learns from 200 filters. Kernel size is ready to 3 x three
which specifies the peak and width of the 2nd convolution F. Plotting the data and training the CNN model:
window. because the model must be aware of the shape of the Fixing the blueprint to survey the records, the project calls
enter predicted the primary layer inside the model desires to be for to be teaches the use of a selected dataset after which to be
furnished with records approximately enter shape. Following tested with respect to a distinct dataset. A proper venture and
layers can carry out instinctive form reckoning. In this situation, more advantageous teach check split assist to produce précised
in-positioned form is specific as information. shape [1:] which end result at the same time as taking a prediction. The test

IJISRT22JUN1511 www.ijisrt.com 1058


Volume 7, Issue 6, June – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
length is ready to 0.1 i.e.,90% records of the dataset undergoes VII. CONCLUSIONS
schooling and the relaxation 10% is going for testing functions.
The validation loss is monitored using version Checkpoint. this text, concisely make clear the inspiration of the task
subsequent, the photos inside the schooling setand the test set at the start. Then, we embellished the enlightenment and
are positioned to the Sequential version. here, 20p.cof the execution of venture of the assignment. with the aid of the usage
training statistics is used as validation statistics. The version is of the essential device mastering matters and clean method the
trained for 20 epochs (iterations) which continues a change-off version has reached valid accuracy charge which may be
among accuracy and probabilities of overfitting. Fig. five utilized in diverse form of software. protecting the face and
depicts visible representation of the proposed version. nostril with face mas may be made obligatory soon, gazing the
Covid scenario. all the public servants will order their personnel
to put on face mask well for persevering with the work inside
the company. The carried out undertaking will be enormously
committed to maintaining the fitness of the public. destiny
enhancement canbe done by extending to detect if the mask
is disease prone ornot i.e., the different types of masks like N95
or not.

REFERENCES

[1]. K.-L. Liuo, N. H. Feng, “Deep learning algorithms for


autonomous detecting”, 2019.
[2]. M. Kumar, Kaur, “Face Mask Detection tutorial review,”
Fig. 5. Summary of the project Artificial Intelligence review, vol. 52, pp.936-948, 2019.
[3]. Z.A. Memish, A.I. Zumla, R.F. Al-Hakeem, A.A. Al-G.
VI. RESULT AND ANALYSIS M. Stephens, “Family cluster of respiratory syndrome
coronavirus infections,” England Journal of Medicine,
The challenge is fashioned, authenticated, and trialed on vol.368, no.26, pp.2487-2494, 2003.
two sort of datasets specifically masked and non-masked [4]. Y. Liu, Gayle A. Smith, “Number of sars coronavirus is
datasets. With appreciate to dataset no 1 i.e., masked dataset, less than novel coronavirus”.
the procedure reaches the precision as much as 98.23%. It [5]. Qin, B. &Li, D. (2020), “Identifying Face mask Detection
represents how this most appropriate precision relieve the rate to prevent coronavirus”.
of error. Dataset quantity 2 is h i g h l y adaptable than dataset [6]. GitHubInc. For coronavirus cases in India till 24 February
n u m b e r 1 as it has multiple faces in the information body 2021.
and numerous sorts of face masks having numerous colors too. [7]. C. Shen, B.J. Hau, “Use off ace mask in coronavirus
therefore, the venture reaches an precision of 94.fifty nine% on pandemic”, the respiratory medicine, 2020.
dataset represent the difference between formed and [8]. Nirmalraj S., and G. Nagarajan. "An adaptive fusion of
authenticated loss with appreciate to dataset number 2. The infrared and visible image based on learning of sparse
critical cause for attaining this precision lies in calculating the fuzzy cognitive maps on compressive sensing". Journal of
maximum price in every patch. It gives an elementary transferal Ambient Intelligence and Humanized Computing (2019).
unchanging to the internal description with minimization in the
wide variety of parameters the project has to examine. This
finite distinction method down-samples the enter description
containing of photograph, by using minimizing its dimensions.
the whole variety of neurons has the greatest value of sixty four
which isn't always clearly huger. a far higher quantity of
neurons and filters can cause worse execution. The ultimate
clear out values and pool size help to kind out the primary
element to come across the photograph to locate the presence
of the face masks nicely with out creating the over fittingness.

Important query as a result of the challenge are specially


associated with different converting angles and shortage of
clearness. blurred constantly converting faces within the video
like format tough to understand. therefore, the distinct issues of
the data frames video assist to take an correct decision – “the
character is with or without masks”.

IJISRT22JUN1511 www.ijisrt.com 1059

You might also like