You are on page 1of 26

Face Mask Detection using Python

CHAPTER 1:

COMPANY PROFILE

Dept. of ECE KSSEM 2022-23 Page 1


Face Mask Detection using Python

Vision is to provide training and implement services with edge of competitive in quality
& price to our valued customers in the ground of sustainability. We promote reputed multi
brand residential, commercial and Industrial automation products. Our focus and growth will
be on the technological outsourcing in the field of PLC controls, BMS, HVAC controls and
other related sub systems in the Middle East and Indian subcontinent.

1.1 MISSION

Mission is to be an ultimate solution provider with a reputation for expertise, quality,


and cost effective in the world of automation and to advocate sustainable environmental
protection by maximizing our consolidated effort through unmatchable teamwork.

 Focus on profitability and return on investments over growth.


 Maintain a lean and flexible organization.
 Employ quality assurance in pursuit of service excellence.
 Practice sound financial management.
 Employ effective project management processes.
 Develop strong project management teams and support systems.

1.2 OBJECTIVES

 Increase the technical knowledge and real time industrial exposure of the students
during the commencement of Industrial Training
 Maximize student’s employability and increase the rate of placement
 Branding of College &wider recognition by Industry and Corporate
 Higher Ranking for the College in Surveys
 Possibility of establishing the Centre of Excellence by the Industry
 Certified and Industry oriented Technical Skills & Personality Development Training
under one window saving cost and Time
 Live Projects and Practice on Real Systems and Instrument

Dept. of ECE KSSEM 2022-23 Page 2


Face Mask Detection using Python

CHAPTER 2:

INTRODUCTION ON FACE MASK DETECTION

Dept. of ECE KSSEM 2022-23 Page 3


Face Mask Detection using Python

The world has not yet fully Recover from this pandemic and the vaccine that can
effectively treat Covid-19 is yet to be discovered. However, to reduce the impact of the
pandemic on the country's economy, several governments have allowed a limited number of
economic activities to be resumed once the number of new cases of Covid19 has dropped below
a certain level. As these countries cautiously restarting their economic activities, concerns have
emerged regarding workplace safety in the new post-Covid-19 environment. To reduce the
possibility of infection, it is advised that people should wear masks and maintain a distance of
at least 1 meter from each other. Deep learning has gained more attention in object detection
and was used for human detection purposes and develop a face mask detection tool that can
detect whether the individual is wearing mask or not. This can be done by evaluation of the
classification results by analyzing real-time streaming from the Camera. In deep learning
projects, we need a training data set. It is the actual dataset used to train the model for
performing various actions.

2.1 EXISTING SYSTEM

Face detection problem has been approached using Multi-Task Cascaded


Convolutional Neural Network (MTCNN). Then facial features extraction is performed using
the Google Face Net embedding model. 1.This system is capable to train the dataset of both
persons wearing masks and without wearing masks. After training the model the system can
predicting whether the person is wearing the mask or not wearing mask.

2.2 PROBLEM STATEMENT

The main objective of the face detection model is to detect the face of individuals and
conclude whether they are wearing masks or not at that particular moment when they are
captured in the image.

2.3 OBJECTIVES:

 In the face detection method, a face is detected from webcam that has several attributes
in it.

 Research into face detection requires expression recognition, face tracking and pose
estimation.

Dept. of ECE KSSEM 2022-23 Page 4


Face Mask Detection using Python

 Here the main challenge of the task is to detect the face from the webcam and then
identify if it has a mask on it or not.

 To Implement this case study, we need a lot of images of people wearing a mask and
not wearing a mask.

2.4 ADVANTAGES

 Helps to prevent the spread of COVID-19: The primary benefit of face mask detection
is that it helps to prevent the spread of COVID-19. The technology can detect whether
a person is wearing a mask or not and alert them to wear one if they are not. This can
help reduce the risk of infection for individuals and communities.
 Automates monitoring and enforcement: Face mask detection technology can automate
the monitoring and enforcement of mask-wearing policies in public places such as
airports, schools, and businesses. This can save time and resources, and ensure that
policies are being followed consistently.
 Increases safety for employees and customers: Face mask detection technology can
create a safer environment for employees and customers by enforcing mask-wearing
policies. This can help reduce the risk of infection and increase confidence in the safety
measures being taken.
 Improves compliance: Face mask detection technology can improve compliance with
mask-wearing policies by providing real-time feedback to individuals who are not
wearing a mask. This can encourage them to comply with the policy and reduce the
need for enforcement.
 Supports public health initiatives: Face mask detection technology can support public
health initiatives by promoting the use of masks as an effective tool to prevent the
spread of infectious diseases. This can help raise awareness and encourage more people
to wear masks in public places.

2.5 APPLICATIONS

 Face mask detection technology can be applied in various settings and industries to
enforce mask-wearing policies and promote public health. Here are some common
applications of face mask detection:

Dept. of ECE KSSEM 2022-23 Page 5


Face Mask Detection using Python

 Face mask detection technology can be used in buses, trains, and subways to ensure
that all passengers are wearing masks. This can help reduce the risk of COVID-19
transmission in these high-density environments
 Retail stores can use face mask detection technology to monitor compliance with mask-
wearing policies and enforce them when necessary. This can create a safer environment
for customers and employees.
 Airports can use face mask detection technology to ensure that all passengers and
employees are wearing masks. This can help reduce the risk of COVID-19 transmission
during air travel.
 Healthcare facilities can use face mask detection technology to monitor compliance
with mask-wearing policies among staff and visitors. This can help prevent the spread
of infectious diseases in these high-risk environments.
 Schools and universities can use face mask detection technology to enforce mask-
wearing policies and ensure that all students, faculty, and staff are following them. This
can help prevent the spread of COVID-19 and other infectious diseases on campus.
 Offices and workplaces can use face mask detection technology to enforce mask-
wearing policies among employees and visitors. This can create a safer environment
for everyone and reduce the risk of COVID-19 transmission in the workplace.
 Sports and entertainment venues can use face mask detection technology to ensure that
all spectators and staff are wearing masks. This can help reduce the risk of COVID-19
transmission during large events.

Dept. of ECE KSSEM 2022-23 Page 6


Face Mask Detection using Python

CHAPTER 3:

LITERATURE SURVEY

Dept. of ECE KSSEM 2022-23 Page 7


Face Mask Detection using Python

3.1 An Automated System to Limit COVID-19 Using Facial Mask Detection


in Smart City Network [1]: COVID-19 pandemic caused by novel coronavirus is
continuously spreading until now all over the world. The impact of COVID-19 has been fallen
on almost all sectors of development. The healthcare system is going through a crisis. Many
precautionary measures have been taken to reduce the spread of this disease where wearing a
mask is one of them. In this paper, we propose a system that restrict the growth of COVID-19
by finding out people who are not wearing any facial mask in a smart city network where all
the public places are monitored with Closed-Circuit Television (CCTV) cameras. While a
person without a mask is detected, the corresponding authority is informed through the city
network. A deep learning architecture is trained on a dataset that consists of images of people
with and without masks collected from various sources. The trained architecture achieved
98.7% accuracy on distinguishing people with and without a facial mask for previously unseen
test data. It is hoped that our study would be a useful tool to reduce the spread of this
communicable disease for many countries in the world.

3.2 Masked Face Recognition Using Convolutional Neural Network [2]:


Recognition from faces is a popular and significant technology in recent years. Face alterations
and the presence of different masks make it too much challenging. In the real-world, when a
person is uncooperative with the systems such as in video surveillance then masking is further
common scenarios. For these masks, current face recognition performance degrades. An
abundant number of researches work has been performed for recognizing faces under different
conditions like changing pose or illumination, degraded images, etc. Still, difficulties created
by masks are usually disregarded. The primary concern to this work is about facial masks, and
especially to enhance the recognition accuracy of different masked faces. A feasible approach
has been proposed that consists of first detecting the facial regions. The occluded face detection
problem has been approached using Multi-Task Cascaded Convolutional Neural Network
(MTCNN). Then facial features extraction is performed using the Google Face Net embedding
model.

Dept. of ECE KSSEM 2022-23 Page 8


Face Mask Detection using Python

CHAPTER 4:

DESIGN AND IMPLEMENTATION

Dept. of ECE KSSEM 2022-23 Page 9


Face Mask Detection using Python

Face mask detection using OpenCV can be achieved by using a combination of


computer vision techniques and machine learning algorithms. Dataset creation: Collect a
dataset of images with people wearing and not wearing masks. The images should be labelled
with the corresponding mask/no-mask label. Face detection: Use OpenCV's Haar Cascade
classifier or any other face detection algorithm to detect faces in the images. Face alignment:
Use facial landmark detection to align the detected faces so that they are roughly in the same
orientation. Mask detection: Train a machine learning model using the dataset created in step
1 to classify the aligned faces as wearing or not wearing a mask. You can use a pre-trained
model such as Mobile Net or VGG16 and fine-tune it on your dataset using transfer learning.
Prediction: Apply the trained model to the detected and aligned faces to predict if the person is
wearing a mask or not. Visualization: Draw bounding boxes around the detected faces and label
them with the predicted mask/no-mask label.

4.1 CODE IMPLEMENTATION

Dept. of ECE KSSEM 2022-23 Page 10


Face Mask Detection using Python

Dept. of ECE KSSEM 2022-23 Page 11


Face Mask Detection using Python

Dept. of ECE KSSEM 2022-23 Page 12


Face Mask Detection using Python

Dept. of ECE KSSEM 2022-23 Page 13


Face Mask Detection using Python

4.2 RESULT:

Figure 4.1 No Mask Detected

Figure 4.2 Mask Detected

Dept. of ECE KSSEM 2022-23 Page 14


Face Mask Detection using Python

CHAPTER 5:

BLOCK DIAGRAM

Dept. of ECE KSSEM 2022-23 Page 15


Face Mask Detection using Python

5.1 BLOCK DIAGRAM AND DESCRIPTION

Figure 5.1 Block Diagram of Face Mask Detection

A face mask detection system as shown in the above figure typically involves the use
of a camera, an image processing algorithm, and a notification system to detect whether
individuals are wearing masks properly or not. Here is a block diagram that explains the
different components of a face mask detection system. The camera is the primary input device
that captures the image or video of individuals in a particular area. It is typically placed at an
appropriate location to capture the face of each person. The pre-processing module receives
the image or video feed from the camera and applies image processing techniques to improve
the quality of the images. This step is necessary to reduce noise, adjust brightness and contrast,
and improve image sharpness. The face detection module detects the faces of individuals in the
captured images. It uses algorithms such as Haar cascades,or deep learning-based models to
identify the regions of the image that correspond to the human face. The person face is detected
and labelled with the blue rectangular frame.

Dept. of ECE KSSEM 2022-23 Page 16


Face Mask Detection using Python

CHAPTER 6:

PROPOSED SYSTEM

Dept. of ECE KSSEM 2022-23 Page 17


Face Mask Detection using Python

This system is capable to train the dataset of both persons wearing masks and
without wearing masks.
After training the model the system can predicting whether the person is wearing themask
or not.
It also can access the webcam and predict the result.

6.1 TENSORFLOW FRAMEWORK:


 Tensor flow is an open-source software library.
 Tensor flow was originally developed by researchers and engineers.
 It is working on the Google Brain Team within Google’s Machine Intelligence research
organization the purposes of conducting machine learning and deep neural networks
research.
 It is an opensource framework to run deep learning and other statistical and predictive
analytics workloads.
 It is a python library that supports many classification and regression algorithms and more
generally deep learning.
 TensorFlow is a free and open-source software library for dataflow and differentiable
programming across a range of tasks.
 It is a symbolic math library, and is also used for machine learning applications suchas
neural networks.
 It is used for both research and production at Google, TensorFlow is Google Brain's second-
generation system.
 Version 1.0.0 was released on February 11, While the reference implementation runs on
single devices, TensorFlow can run on multiple CPUs and GPUs (with optional CUDA and
SYCL extensions for general-purpose computing on graphics processing units).
 Tensor Flow is available on 64-bit Linux, macOS, Windows, and mobile computing
platforms including Android and iOS.

6.2 OPENCV:
 It is a cross-platform library using which we can develop real-time computer vision
applications.
 It mainly focuses on image processing, video capture and analysis including feature like
face detection and object detection.

Dept. of ECE KSSEM 2022-23 Page 18


Face Mask Detection using Python

 Currently Open CV supports a wide variety of programming languages like C++, Python,
 Java etc. and is available on different platforms including Windows, Linux, OS X, Android,
iOS etc.
 Also, interfaces based on CUDA and OpenCL are also under active development for
 high-speed GPU operations. Open CV-Python is the Python API of Open CV.
 It combines the best qualities of Open CV C++ API and Python language.
 OpenCV (Open-Source Computer Vision Library) is an opensource computer vision and
machine learning software library. OpenCV was built to provide a common infrastructure
for computer vision applications
 and to accelerate the use of machine perception in the commercial products. Being a BSD-
licensed product, OpenCV makes it easy for businesses to utilize and modify the code.
 The library has more than 2500optimized algorithms, which includes a comprehensive set
of both classic and state-of -the-art computer vision and machine learning algorithms.
 Algorithms can be used to detect and recognize faces, identify objects, classify human
actions in videos, track camera movements, track moving objects, extract 3D models of
objects, produce 3D point clouds from stereo cameras, stitch images together to produce a
high resolution image of an entire scene, find similar images from an image database,
remove red eyes from images taken using flash, follow eye movements, recognize scenery
and establish markers to overlay it with augmented reality, etc.

6.3 NUMPY:
NumPy is a library for the Python programming language, adding support for large,
multi-dimensional arrays and matrices, along with a large collection of high- level
mathematical functions to operate on these arrays. The ancestor of NumPy, Numeric, was
originally created by Jim Hugunin with contributions from several otherdevelopers. In 2005,
Travis Oliphant created NumPy by incorporating features of the competing Num array into
Numeric, with extensive modifications. NumPy is open- source software and has many
contributors.

The Python programming language was not initially designed for numericalcomputing,
but attracted the attention of the scientific and engineering community early on, so that a special
interest group called matrix-sig was founded in 1995 with the aim of defining an array
computing package. Among its members was Python designer and maintainer Guido van

Dept. of ECE KSSEM 2022-23 Page 19


Face Mask Detection using Python

Rossum, who implemented extensions to Python's syntax (in particular the indexing syntax) to
make array computing easier.

An implementation of a matrix package was completed by Jim Fulton, then generalized by


Jim Hugunin to become Numeric also variously called Numerical Python extensions or NumPy
Hugunin, a graduate student at Massachusetts Institute of Technology (MIT) joined the
Corporation for National Research Initiatives (CNRI) to work on J Python in 1997 leaving Paul
Dubois of Lawrence Livermore National Laboratory (LLNL) to take over as maintainer.

In early 2005, NumPy developer Travis Oliphant wanted to unify the community around
a single array package and ported num-array's features to Numeric, releasing the result as
NumPy 1.0 in 2006. This new project was part of SciPy. To avoidinstalling the large SciPy
package just to get an array object, this new package was separated and called NumPy.

6.4 KERAS
KERAS is an API designed for human beings, not machines. Keras follows best
practices for reducing cognitive load: it offers consistent & simple APIs, it minimizes the
number of user actions required for common use cases, and it provides clear & actionable error
messages.

It also has extensive documentation and developer guides. Keras contains numerous
implementations of commonly used neural network building blocks such as layers, objectives,
activation functions, optimizers, and a host of tools to make working with image and text data
easier to simplify the coding necessary for writing deep neural network code.

The code is hosted on GitHub, and community support forums include the GitHub issues
page, and a Slack channel. Keras is a minimalist Python library for deeplearning that can run
on top of Theano or Tensor Flow.

It was developed to make implementing deep learning models as fast and easy as
possible for research and development.

Dept. of ECE KSSEM 2022-23 Page 20


Face Mask Detection using Python

6.5 MACHINE LEARNING APPROACHES:


1.Viola–Jones object detection framework based on HAAR Features
2. Scale-invariant feature transform (SIFT)
3.Histogram of oriented gradients (HOG) features

Machine learning (ML)is the study of computer algorithms that improve automatically
through experience. Itis seen as a subset of artificial intelligence. Machine learning algorithms
build a mathematical model based on sample data, known as "training data", in order to make
predictions or decisions without being explicitly programmed to do so. Machine learning
algorithms are used in a wide variety of applications, such as email filtering and computer
vision, where it is difficult or infeasible to develop conventional algorithms to perform the
needed tasks. Machine learning is closely related to computational statistics, which focuses on
making predictions using computers. The study of mathematical optimization delivers
methods, theory and application domains to the field of machine learning. Data mining is a
related field of study, focusing on exploratory data analysis through unsupervised learning. In
its application across business problems, machine learning is also referred to as predictive
analytics.

1. Viola-Jones Object detection framework based in HAARfeatures:


The Viola-Jones algorithm is one of the most popular algorithms for objects
recognition in an image. This research paper deals with the possibilities of parametric
optimization of the Viola-Jones algorithm to achieve maximum efficiency of thealgorithm in
specific environmental conditions. It is shown that with the use ofadditional modifications it
is possible to increase the speed of the algorithm in a particular image by 2-5 times with the
loss of accuracy and completeness of the workby not more than the 3-5%.

2. Scale-invariant feature transform (SIFT):


The scale-invariant feature transform (SIFT) is a feature detection algorithm in computer
vision to detect and describe local features in images. SIFT key points of objects are first
extracted from a set of reference images and stored in a database. An object is recognized in a
new image by individually comparing each feature from the new image to this database and
finding candidate matching features based on Euclidean distance of their feature vectors. From
the full set of matches, subsets of keypoints that agree on the object and its location, scale, and

Dept. of ECE KSSEM 2022-23 Page 21


Face Mask Detection using Python

orientation in the new image are identified to filter out good matches.

3. Histogram of oriented gradients (HOG):


The histogram of oriented gradients (HOG) is a feature descriptor used in computer
vision and image processing for the purpose of object-detection. The technique counts
occurrences of gradient orientation in localized portions of an image. This method issimilar
to that of edge orientation histograms, scale-invariant feature transformdescriptors, and
shape contexts, but differs in that it is computed on an algorithm is involved in this proposed
systemHAAR Feature-Based Cascade Classifiers.

In deep learning, a convolutional neural network (CNN, or ConvNet) isa class of deep,
feed-forward artificial neural networks, most commonly applied to analyzing visual imagery.

Convolutional networks were inspired by biological processes in that the connectivity


pattern between neurons resembles the organization of the visual cortex. CNNs use relatively
little pre-processing compared to other image classification algorithms. CNN is a special kind
of multi- layer NNs applied to 2-d arrays (usually images), based on spatially localized neural
input. CNN Generate ‘patterns of patterns’ for pattern recognition.

Each layer combines patches from previous layers. Convolutional Networks are
trainable multistage architectures composed of multiple stages Input and output of each stage
are sets of arrays called feature maps. At output, each feature maprepresents a particular feature
extracted at all locations on input. Each stage is composed of: a filter bank layer, a non-linearity
layer, and a feature pooling layer. A ConvNet is composed of 1, 2 or 3 such 3-layer stages,
followed by a classification module.

Dept. of ECE KSSEM 2022-23 Page 22


Face Mask Detection using Python

CHAPTER 7:
FLOW CHART

Dept. of ECE KSSEM 2022-23 Page 23


Face Mask Detection using Python

7.1 FLOW CHART AND DESCRIPTION

No

Yes

Figure 7.1 Flow chart

First the collection of data of faces with mask and without mask are done as shown in Figure 7.1.
The data is stored in the format of NumPy. The data with no masks are labelled as 0, similarly the
data with masks are labelled as 1. The data collection process ends.

The Mask detection process starts by accessing the camera, if the camera access is granted the face
detection process starts and creates a frame around the face. If the mask is detected it prints as
“mask” else it prints as “No mask” until the ESC key is pressed.

Dept. of ECE KSSEM 2022-23 Page 24


Face Mask Detection using Python

REFERENCES

Dept. of ECE KSSEM 2022-23 Page 25


Face Mask Detection using Python

[1] M. S. Ejaz and M. R. Islam, "Masked Face Recognition Using Convolutional Neural Network,"
2019 International Conference on Sustainable Technologies forIndustry 4.0 (STI), 2019, pp. 1-6,
doi: 10.1109/STI47673.2019.9068044.

[2] M. R. Bhuiyan, S. A. Khushbu and M. S. Islam, "A Deep Learning Based AssistiveSystem to
Classify COVID-19 Face Mask for Human Safety with YOLOv3," 2020 11th International
Conference on Computing, Communication and Networking Technologies (ICCCNT)

[3] M. M. Rahman, M. M. H. Manik, M. M. Islam, S. Mahmud and J. -H. Kim, "AnAutomated


System to Limit COVID-19 Using Facial Mask Detection in Smart CityNetwork," 2020 IEEE
International IOT, Electronics and Mechatronics Conference (IEMTRONICS), 2020

[4] Y. Sun, Y. Chen, X. Wang, and X. Tang, “Deep learning face representation by joint
identification-verification,” in Advances in neural information processing systems, 2014, pp.
198hy, A. Khosla, M. Bernstein, A. C. Berg, and L. Fei-Fei, “ImageNet Large Scale Visual
Recognition Challenge,” 2014.

[5] F. S. Samaria and A. C. Harter, “Parameterisation of a stochastic model for human face
identification,” in Applications of Computer Vision, 1994., Proceedings of the Second IEEE
Workshop on, pp. 138–142, IEEE, 1994.

[6] D. Yi, Z. Lei, S. Liao, and S. Z. Li, “Learning face representation from scratch,” CoRR
abs/1411.7923, 2014.

[7] X. Cao, D. Wipf, F. Wen, G. Duan, and J. Sun, “A practical transfer learning algorithm for
face verification,” in Computer Vision (ICCV), 2013 IEEE International Conference on, pp.
3208–3215, IE8–1996.

[8] W. Zhao, R. Chellappa, P. J. Phillips, and A. Rosenfeld, “Face recognition: Aliterature


survey,” ACM computing surveys (CSUR), vol. 35, no. 4, pp. 399–458,2003.

[9] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A.KarpatEE, 2013.

Dept. of ECE KSSEM 2022-23 Page 26

You might also like