Professional Documents
Culture Documents
A report submitted in partial fulfilment of the requirements for the award of the degree of
BACHELOR OF TECHNOLOGY
in
Electronics and Communication Engineering
By
GAURAV KUMAR (19220)
SCHOOL OF ELECTRONICS/COMPUTING
MAY 2022
BONAFIDE CERTIFICATE
This is to certify that the project titled Face Mask Detection is a bonafide record of the
work done by
in partial fulfilment of the requirements for the award of the degree of Bachelor of
Technology in ECE of the INDIAN INSTITUTE OF INFORMATION TECHNOLOGY
UNA, HIMACHAL PRADESH, during the year 2019 - 2023.
i
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
ORIGNALITY / NO PLAGARISM DECLARATION
I certify that this internship report is my original report and no part of it is copied from any
published reports, papers, books, articles, etc. I certify that all the contents in this report are
based on my personal findings and research and I have cited all the relevant sources which
have been required in the preparation of this project report, whether they be books, articles,
reports, lecture notes, and any other kind of document. I also certify that this report has not
previously been submitted partially or as whole for the award of degree in any other
university in India and/or abroad.
I hereby declare that, I am fully aware of what constitutes plagiarism and understand that if
it is found at a later stage to contain any instance of plagiarism, my degree may be
cancelled.
ii
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
ABSTRACT
iii
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
ACKNOWLEDGEMENT
I would like to thank the following people for their support and guidance without whom the
completion of this internship in fruition would not be possible.
I would like to express my sincere gratitude and heartfelt thanks to Dr. Vanita Arora for the
unflinching support and guidance, valuable suggestions and expert advice. her words of
wisdom and expertise in subject matter were of immense help throughout the duration of
this project.
I also take the opportunity to thank our Director and all the faculty of School of
Computing/Electronics, IIIT Una for helping me by providing necessary knowledge base
and resources.
I would also like to thank my parents, brother and friends for their constant support.
iv
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEGEMENT iv
TABLE OF CONTENTS v
1 Introduction 1-2
2 Working 3-4
3 Result 5-6
4 Conclusion 7
Appendices 8-12
v
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
Chapter 1
Introduction
COVID-19 has had a big impact on human lives. The pandemic led to the loss
of millions and affected the lives of billions of people. Its negative impact was
felt by almost all commercial establishments.
After the person gets infected, it takes almost fourteen days for the virus to
grow in the body of its host and affect them and in the meantime, it spreads to
almost everyone who is in contact with that person. So, it is extremely hard to
keep the track of the spread of COVID-19. COVID-19 mainly spreads through
droplets produced as a result of coughing or sneezing by an infected person.
This transfers the virus to any person who is in direct close contact (Within
one-meter distance) with the person suffering from coronavirus. Because of
this, the virus spreads rapidly among the masses. With the nationwide
lockdowns being lifted, it has become even harder to track and control the
virus. Face masks are an effective method to control the spread of virus. The
governments, all over the world, have imposed strict rules the everyone should
wear masks while they go out. But still, some people may not wear masks and
it is hard to check weather everyone is wearing mask or not.
In such cases, computer vision will be of great help. There are no efficient
face mask detection applications to detect weather the person is wearing face
mask or not. This increases the demand for an efficient system for detecting
face masks on people for transportation means, densely populated areas,
residential districts, large-scale manufacturers and other enterprises to ensure
safety. This project uses machine learning classification using OpenCV and
TensorFlow to detect facemasks on people.
1
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
OPENCV:
TENSORFLOW:
2
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
Chapter 2
Working
This project makes the use of OpenCV, Caffe-based face detector, Keras,
TensorFlow and MobileNetV2 for the detection of face mask on humans. The
dataset which is being used contains 3833 images out of which 1915 images
have people with masks in them and 1918 people without masks in them.
Dataset Collection: The dataset was collected from Kaggle Repository and
was split into training and testing data after its analysis.
Training a model to detect face masks: A default OpenCV module was used
to obtain faces followed by training a Keras model to identify face mask.
Detecting the person not wearing a mask: A OpenCV model was trained to
detect the names of the people who are not wearing masks by referring the
database.
A base model is generated by using Keras and MobileNetV2. The generated
model is then trained with the labeled dataset by splitting it into two portions.
One portion contains 80 percent images and it is used for training. The
remaining portion contains the remaining 20 percent of images and is used for
testing the model accuracy. After the model is trained, it can be used for
detection of facemask on human faces. The trained model is loaded and image
which contains human faces with or without masks or a continuous video
stream with humans is given as input.
The image or a frame of the video, in case the input is a video stream, is first
sent to the default face detector module for the detection of human faces. This
is done by resizing the image or the video frame first, followed by detecting
the blob in it. This detected blob is sent to the face detector model which
outputs only the cropped face of a person without the background. This face is
given as the input to the model which we trained earlier. This outputs weather
there is a mask or not.
3
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
4
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
RESULT
5
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
CONCLUSION
With the increasing number of COVID cases all over the world, a system to
replace humans to check masks on the faces of people is greatly needed. This
system satisfies that need. This system can be employed in public places like
railway stations and malls. It will be of a great help in companies and huge
establishments where there will be a lot of workers. This system will be of a
great help there because it is easy to obtain and store the data of the employees
working in that Company and will very easily find the people who are not
wearing the mask and a mail will sent to that respective person to take
Precautions not wearing mask.
6
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
Appendices
7
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
Appendix A
Code Attachments
The following is the partial / subset of the code. Code of some module(s) have been
wilfully supressed.
# pass the blob through the network and obtain the face detections
faceNet.setInput(blob)
detections = faceNet.forward()
print(detections.shape)
8
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
# the detection
confidence = detections[0, 0, i, 2]
9
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
# load the face mask detector model from disk
maskNet = load_model("mask_detector.model")
10
School of Electronics/Computing, IIITU [Internship code] : IIITU19220
if key == ord("q"):
break
# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()
11
School of Electronics/Computing, IIITU [Internship code] : IIITU19220