Face Mask Detection Using Machine Learning Final Report
Face Mask Detection Using Machine Learning Final Report
A PROJECT REPORT
Submitted by
BACHELOR OF ENGINEERING
IN
Chandigarh University
2022-2023
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
SUPERVISOR
HEAD OF THE DEPARTMENT
Timeline ......................................................................................................................................... 9
Goals/Objectives.......................................................................................................................... 11
Design Flow................................................................................................................................. 14
Design selection........................................................................................................................... 14
Future work.................................................................................................................................. 29
REFERENCES........................................................................................................ 31
List of Figures
Figure 1.4.1 ………………………………………………………………….…………….Gantt Chart
Publishing
Standard About the standard Page no
Agency
IEEE 802.11 is part of the IEEE
802 set of local area network
(LAN) technical standards and
specifies the set of media access
IEEE Mention page nowhere standard
IEEE control (MAC) and physical layer
802.11 is used
(PHY) protocols for
implementing wireless local area
network (WLAN) computer
communication.
The COVID-19 pandemic has brought about unprecedented changes in the way we live our
lives. One of the critical measures that have been adopted globally to curb the spread of the
virus is the use of face masks. Face masks act as a barrier between the individual wearing
them and others, reducing the chances of transmission of the virus. However, ensuring that
individuals wear face masks in public spaces can be challenging, especially in crowded
areas.
The use of technology can play a significant role in addressing this challenge. Machine
learning, a subfield of artificial intelligence, has shown great potential in accurately
detecting whether or not a person is wearing a face mask. In recent years, deep learning
models such as Convolutional Neural Networks (CNNs) have shown remarkable success in
image classification tasks, including face mask detection.
The objective of this project is to develop a machine learning model using CNNs that can
accurately detect whether or not a person is wearing a face mask in real-time. The model
will be trained on a dataset of images with and without face masks and tested for its
accuracy and efficiency. Once developed, the model can be deployed in public spaces such
as airports, hospitals, and public transport systems, enabling authorities to monitor
compliance with the use of face masks and ensure public safety.
The need for an accurate and efficient face mask detection model Is crucial In the fight
against COVID-19. Face masks are a critical tool in reducing the spread of the virus, and
ensuring their proper use in public spaces is essential for public safety. This project aims to
address this need and provide a solution that can be deployed in real-time, helping
authorities monitor compliance with the use of face masks.
The remainder of the report will be organized as follows: a review of previous studies on
face mask detection using machine learning and CNNs, a description of the dataset used, the
methodology used to develop the model, the results of the model evaluation, a discussion of
the implications and limitations of the study, and a conclusion summarizing the findings and
recommendations for future research.
1.1 Identification of Client /Need / Relevant Contemporary issue
The COVID-19 pandemic has created an urgent need for the use of face masks in public
places. Despite the importance of wearing masks, many individuals still refuse to comply
with the recommendations, leading to the spread of the virus. The need to find a solution to
detect and alert non-compliance of face mask usage in real-time has become increasingly
important.
The client for this project could be any organization or entity that wants to monitor
compliance with face mask usage. Examples of such organizations include government
agencies, transportation companies, and retail stores.
Several reports and statistics have documented the impact of COVID-19 on the world.
According to the World Health Organization (WHO), as of March 2021, over 118 million
cases of COVID-19 had been reported globally, resulting in over 2.6 million deaths. The use
of face masks has been proven to reduce the risk of contracting the virus, and therefore, the
non-compliance of mask usage poses a significant challenge to controlling the spread of the
virus.
The problem at hand is the accurate detection of whether or not a person is wearing a face
mask in real-time. This problem is critical in reducing the spread of COVID-19 and ensuring
public safety. However, detecting face masks accurately and efficiently is a complex task that
requires the use of advanced technologies such as machine learning.
1.3.1 Gathering and preparing a dataset of images with and without face masks.
1.3.2 Developing a machine learning model using convolutional neural networks (CNNs) to
detect face masks.
1.3.3 Training the model using the prepared dataset.
1.3.4 Testing the accuracy and efficiency of the model.
1.3.5 Deploying the model in real-time for face mask detection.
1.4 Timeline
The timeline for this project is as follows:
Figure: 1.4.1
1. Introduction: This section will provide background information on the project, identify
the client and need, and introduce the problem and tasks required for the project.
2. Literature Review: This section will review previous studies on face mask detection
using machine learning and CNNs.
3. Methodology: This section will describe the dataset used, data pre-processing techniques,
model architecture, training process, and evaluation metrics used.
4. Results: This section will present the quantitative and qualitative evaluation results of the
model, including a comparison with state-of-the-art methods.
5. Discussion: This section will interpret the results, discuss the limitations of the study, and
suggest future improvements.
6. Conclusion: This section will summarize the findings, implications, and significance of
the study, and provide recommendations for future research.
7. References: This section will include a list of sources used in the report.
CHAPTER 2.
LITERATURE REVIEW/BACKGROUND STUDY
2.1. Timeline of the reported problem
The use of face masks as a preventive measure for respiratory diseases is not a new concept.
However, the COVID-19 pandemic brought renewed attention to the importance of face
masks in preventing the spread of the disease. The problem of people not wearing masks or
wearing them improperly has been identified since the beginning of the pandemic in early
2020. Documentary proof of this can be found in news reports, social media posts, and
official guidelines issued by health organizations and governments worldwide.
This project aims to address these limitations by developing a machine learning model that
can accurately detect face masks even in challenging real-world scenarios. The project also
aims to train the model on a diverse dataset, develop a user-friendly interface for the system,
validate its accuracy through testing and evaluation, and ensure its scalability for real-time
use. The focus of this project is to develop a solution that is accurate, reliable, and adaptable
to real-world scenarios.
Thus, the findings of the literature review have informed the goals and objectives of this
project and will guide the development of a robust face mask detection system that can be
deployed in various settings.
2.6. Goals/Objectives
The goals and objectives of this project are:
• To develop a machine learning model that can accurately detect face masks in real-
world scenarios.
• To train the model on a diverse dataset to improve its accuracy and reliability.
• To develop a user-friendly interface for the system.
• To validate the accuracy of the system through testing and evaluation.
• To make the system adaptable to different environments and lighting conditions.
• To ensure the system is scalable and can handle large volumes of data in real-time.
CHAPTER 3.
DESIGN FLOW/PROCESS
3.1. Evaluation & Selection of Specifications/Features
In this project, we aim to develop a system for detecting the presence or absence of a face
mask using machine learning techniques. To achieve this, we conducted a literature review
and identified the following features that are ideally required in the solution:
Based on the literature review, the following features are ideally required in the solution for
face mask detection using machine learning:
Face detection: The ability to detect faces accurately is a crucial step in the mask
detection process.
Mask detection: The system should be able to detect whether a person is wearing a mask
or not.
Mask fitting: The system should be able to detect whether the mask is being worn
correctly, covering both the nose and mouth.
Occlusion handling: The system should be able to handle situations where the face is
partially or completely occluded by objects or other people.
Real-time processing: The system should be able to process and detect masks in real-
time.
Accuracy: The system should have a high level of accuracy in detecting masks in various
scenarios.
Dataset diversity: The system should be trained on a diverse dataset to improve its
accuracy and generalization ability.
User-friendly interface: The system should have a user-friendly interface that is easy to
use and understand.
Scalability: The system should be scalable for real-time use in various settings.
3.2. Design Constraints
The design of the face mask detection system must comply with various regulations,
including economic, environmental, health, safety, professional, ethical, social, and political
issues. The cost should also be considered in the design process.
Standards: We need to ensure that our solution complies with regulatory standards for
accuracy and performance. Additionally, we need to consider economic, environmental, and
health factors in the design.
Safety: We need to ensure that our solution is safe to use and does not pose any risk to the
user or the public.
Professional and ethical considerations: We need to ensure that our solution is designed
and implemented in a professional and ethical manner, taking into account issues such as
privacy and data security.
Social and political issues: We need to consider the social and political implications of our
solution, particularly in light of the ongoing COVID-19 pandemic.
Considering the design constraints, the following modifications and additions can be made to
the features:
Face detection: The accuracy of face detection should be balanced with the computational
resources required for real-time processing, considering the cost and environmental impact.
Mask detection: The system should be designed to handle different types of masks,
including cloth masks, surgical masks, and N95 masks, while taking into account the cost and
availability of the different types of masks.
Mask fitting: The system should be able to detect incorrect mask fitting, but it should not
invade the privacy of the user or cause discomfort.
Occlusion handling: The system should be able to handle occlusion to a certain extent
without compromising accuracy, while taking into account the privacy and ethical concerns
of the user.
Real-time processing: The system should be optimized for real-time processing while
minimizing the computational resources required, taking into account the economic and
environmental impact.
Accuracy: The system should be designed to achieve a reasonable level of accuracy while
balancing the computational resources required, considering the cost and environmental
impact.
Dataset diversity: The system should be trained on a diverse dataset that includes data from
different settings, cultures, and demographics to improve its accuracy and generalization
ability.
User-friendly interface: The system should have a simple and intuitive interface that does
not require specialized training to use.
Scalability: The system should be designed to scale for real-time use in various settings
while taking into account the cost and environmental impact.
Design 1: This design uses a convolutional neural network (CNN) for face detection,
followed by a separate CNN for mask detection. The two CNNs are trained independently
and combined at runtime to detect the presence or absence of a face mask.
Design 2: This design uses a single CNN for joint face and mask detection. The CNN is
trained end-to-end on a dataset of images containing faces with and without masks.
Simplicity: Design 2 is simpler than Design 1 since it uses a single CNN for joint face and
mask detection, which reduces computational complexity and memory requirements.
Data Preprocessing: Once the dataset is collected, the images will be preprocessed to ensure
they are of high quality and uniform size. This will involve techniques such as resizing,
normalization, and augmentation.
Feature Extraction: The next step will be to extract features from the preprocessed images.
The features will include color, texture, and shape, as identified in the literature review. The
feature extraction process will involve techniques such as histogram of oriented gradients
(HOG), local binary patterns (LBP), and color histograms.
Model Development: After feature extraction, the extracted features will be used to train a
machine learning model. The model will use a deep learning algorithm such as a
convolutional neural network (CNN). The model will be trained on the extracted features to
recognize faces with and without masks.
Model Evaluation: The trained model will be evaluated using a test dataset that was not used
in the training process. The evaluation will involve metrics such as accuracy, precision,
recall, and F1 score. The evaluation will help determine the effectiveness of the model in
detecting masks in real-world scenarios.
User Interface Development: Once the model is developed and evaluated, a user interface
will be developed to make it easy to use the system. The user interface will allow users to
upload images or videos to be analyzed by the model and will display the results of the
analysis.
Deployment: After the model is developed, evaluated, and the user interface is created, the
system will be deployed. The system will be deployed on a cloud platform to make it
accessible from anywhere.
Maintenance: The system will be maintained and updated as necessary to ensure it remains
accurate and effective. This will involve regular updates to the training data and model as
new images and videos become available.
The above methodology will be followed to develop a robust face mask detection system that
is accurate, reliable, and adaptable to real-world scenarios.
To visualize the design flow and methodology, we have created a flowchart (see Figure 1)
that outlines the key steps in the development of our face mask detection system.
Figure: 3.6.1
Algorithms:
Step 1: Start
Step 2: Load Libraries.
Step 3: Create a data directory with data set.
Step 4: Create two classes with mask and without mask.
Step 5: Load the data set.
Step 6: Convert images to same size.
Step 7: Create data training function, shuffle all data set images.
Step 8: Create data into pickle format with pickle in and pickle out.
Step 9: Now train the model from TensorFlow MobileNet.
Step 10: Feed required input to train your model.
Step 11: Train the model with required epochs.
Step 1: Save new model as trained model Hs file.
Step 13: Load haar cascade file.
Step 14: Load the model.
Step 15: Detect images and videos.
Step 16: Apply the face mask classifier to each face ROI.
Step 17: If with mask -no alarm if without mask -raise alarm.
Step 18: End the execution.
In summary, our face mask detection system will involve data collection, pre-processing,
model selection and training, model evaluation, deployment, and maintenance. We have
selected Design 2, which uses a single CNN for joint face and mask detection, as the best
option for our system, based on its simplicity, accuracy, and real-time performance. We
believe that our system has the potential to make a significant contribution to public health
and safety during the ongoing COVID-19 pandemic.
CHAPTER 4.
RESULTS ANALYSIS AND VALIDATION
Figure: 4.1.1
Figure 4.1.2
Figure 4.2.1
BLOCK DIAGRAM
Figure 4.2.2
DATA FLOW DIAGRAM
Figure: 4.2.3
4.3. CODE IMPLEMENTATION
Training the dataset
Detection of Face Mask
4.4.1. FUNCTIONAL REQUIREMENTS
The main purpose of computer results is to provide processing results to the user. They
are also used to permanently record results for future use. In general, there are many
different types of results.
• External results are results that are exported outside the company.
• Visible in Power Users and Computers,
• location within the organization.
• Operational results are for IT use only.
• UI results allow the user can directly interact with the system.
• Understand user preferences, skill levels, and needs to ask questionsabout
your company through friendly surveys.
SOFTWARE REQUIREMENTS
• Python 3.5 in PyCharm is used for data pre-processing, model training, and more.
• Operating System: Windows 7 or higher, Linux-based operating system, or MAC
OS
• Programming language: Python.
• Nvidia graphics processor
CHAPTER 5
CONCLUSION AND FUTURE WORK
5.1. CONCLUSION:
The project "Face Mask Detection Using Machine Learning" aimed to develop a system that
can accurately detect whether a person is wearing a face mask or not, using machine learning
techniques. The system has been successfully implemented and evaluated, and the following
conclusions can be drawn from the project.
Figure 5.2.1
I. Chavda A., Dsouza J., Badgujar S. and Damani A. “Multi-stage CNN architecture for
face mask detection”. In2021 6th International Conference for Convergence in
Technology (I2CT) 2021 Apr 2 (pp. 1-8). IEEE.
II. Jignesh Chowdary G., Punn NS., Sonbhadra SK. and Agarwal S. “Face mask
detection using transfer learning of inceptionv3”. In International Conference on Big
Data Analytics 2020 Dec 15 (pp. 81-90). Springer, Cham.
III. Mohan P., Paul AJ., Chirania A. and A tiny “CNN architecture for medical face mask
detection for resource-constrained endpoints”. In Innovations in Electrical and
Electronic Engineering 2021 (pp. 657-670). Springer, Singapore.
IV. Wang Z., Wang P., Louis PC., Wheless LE. And Huo Y. “Wear mask: Fast in-
browser face mask detection with server less edge computing for covid-19”. ArXiv
preprint arXiv: 2101.00784. 2021 Jan 4.
VI. Zhang J., Han F., Chun Y. and Chen W. “A novel detection framework about
conditions of wearing facemask for helping control the spread of covid-19”. IEEE
Access. 2021 Mar 17; 9:42975-84.
VII. Meenpal T., Balakrishnan A. and Verma A. “Facial mask detection using semantic
segmentation”. In2019 4th International Conference on Computing, Communications
and Security (ICCCS) 2019 Oct 10 (pp. 1-5). IEEE.
VIII. Jiang X., Gao T., Zhu Z. and Zhao Y. “Real-time facemask detection method based
on YOLOv3. Electronics”. 2021 Jan; 10(7):837.
IX. Venkateswarlu IB., Kakarla J. and Prakash S. “Face mask detection using mobile net
and global pooling block”. In2020 IEEE 4th Conference on Information &
Communication Technology (CICT) 2020 Dec 3 (pp. 1-5). IEEE.
X. Adusumalli H., Kalyani D., Sri RK., Pratapteja M. and Rao PP. “Face mask detection
using OpenCV”. In2021 Third International Conference on Intelligent
Communication Technologies and Virtual Mobile Networks (ICICV) 2021 Feb 4 (pp.
1304-1309). IEEE.
XI. Addagarla SK., Chakravarthi GK. and Anitha P. “Real time multi-scale facial mask
detection and classification using deep transfer learning techniques”. International
Journal. 2020 Jul; 9(4):4402-8.
XII. Sen S. and Sawant K. “Face mask detection for covid_19 pandemic using pytorch in
deep learning”. InIOP Conference Series: Materials Science and Engineering 2021
Feb 1 (Vol. 1070, No. 1, p. 012061). IOP Publishing.
XIII. Yu J. and Zhang W. “Face mask wearing detection algorithm based on improved
YOLO-v4. Sensors”. 2021 Jan; 21(9):3263.