Mask detecting program

MASK DETECTING PROGRAM  
SVTH: Phạ  Quang  hiến, Ngu ễn Thu Hà,  
Vương  h nh Linh, Trần Thu Hiền, Vũ Văn Tùng  
GVHD: ThS Bùi Quốc Khánh  
     ắ   Mọi người đều được  huyến  hích đeo  h u trang trong suốt sự b ng phát của dịch  
corona để ngăn chặn sự lây lan của virus COVID19 một cách hiệu quả. Tuy nhiên, trên thực tế,  hông  
có nguyên mẫu nhận dạng mặt nạ công  hai nào để giúp tất cả mọi người có thể phát hiện ai đó đeo  
 h u trang  hi tham gia vào n i công cộng như trong nhà máy, công ty, trường học, v.v ... Điều này  
hoàn toàn làm cho công nghệ nhận dạng khuôn mặt hiện tại trong nhiều trường hợp không thành  
công. Do đó, dựa trên nghiên cứu thứ cấp, bài viết này thảo luận về việc phát hiện mặt nạ để nâng  
cao chất lượng nhận dạng trên khuôn mặt đeo mặt nạ từ các công nghệ nhận dạng khuôn mặt hiện  
tại, miêu tả bộ dữ liệu, thư viện, phư ng pháp, thuật toán được sử dụng để phát triển dự án. Tóm lại,  
bài viết rút ra kết luận rằng mục đích của ứng dụng này là vì sức khỏe của cộng đồng, góp phần vào  
tình hình  hó  hăn của thế giới hiện nay, để đ y lùi dịch bệnh nhanh chóng.  
Abstract: Everybody is encouraged to wear face mask during coronavirus outbreak to prevent  
the spread of COVID19 virus effectively. Actually, however, there is no public masked face recognition  
prototypes to help all people can detect someone wearing a mask when joining in society such as in  
factory, company, school, etc. This totally makes current facial recognition technology in many cases  
unsuccessful. Therefore, this paper, based on secondary research, discusses about mask detection  
enhancing identification quality on masked faces from current face recognition technologies, describes  
which dataset, library, methodlogy, algorithm used to develop project. All in all, the paper draws the  
conclusion that the purpose of this application is for the health of the community, contributing to the  
difficult situation of the world today, to repel the epidemic quickly.  
Keywords: Convolutional Neural Network (CNN), Fully-connected layers (FC layers), fune-  
tuning, Keras, MobileNetV2, Convolution layers (CONV layers).  
I. INTRODUCTION  
A large and increasing outbreak of a novel coronavirus first emerged in Wuhan, China's  
Hubei province in December 2019 Invalid source specified. that also can lead to acute lung  
infections, including fatal acute respiratory distress syndrome Invalid source specified.. The  
new coronavirus has been confirmed with transmission from human to human Invalid source  
specified., because of the massive transport and high population freedom of movement before  
the Lunar New Year, this new coronavirus has spread very quickly to other areas of the world  
with fatal consequences. COVID-19 has become a dangerous pandemic threatening to life of  
people all over the world.  
To avoid outbreaks of disease, WHO recommends some measures that people should do  
to protect themselves from virus and one of these is wearing a medical mask. Whenever and  
wherever they are, following the instructions for putting on, taking off, and disposing of  
medical masks, avoid crowded groups and enclosed areas Invalid source specified..  
56  
Nevertheless, opposite to widely spread news and announcements around the world, there are  
still some individuals who are unaware of protecting their own safety, not wearing masks as  
required by government, that affect the community.  
Face detection has also been an important research field of the vision community over  
the past two decades. Marian found that in the video stream, the device automatically detects  
frontal faces and codes each frame in terms of dimensions: optimistic, furious, disgusting,  
afraid, happy, sorrow, and disappointmentInvalid source specified.. Sachin mentioned her  
approach follows some works but constructs a deeper CNN for the detection of the face  
Invalid source specified.. Oliver‘s research showed that a quick face recognition scan  
algorithm was introduced and the model may be constructed using different methods: Neural  
Networks and Support Vector Machines,etcInvalid source specified.. In other article,  
Shaumik also reported about this title with difference library which is KerasInvalid source  
specified. According to him, in Keras, he would use a pre-trained MTCNN model to detect  
faces in the images. Once he had extracted the faces from a picture, he will calculate a score  
of similarity between those faces to figure out if they belong to the same individual.  
Ironically, up until now there have been no research written about mask detection, some  
journalists have tried to approach the article, but none of them reflect the focus of the topic.  
Face recognition - the most essential means of identification, had almost failed in the age of  
COVID19, such as public entry and exit, face attendance, face gates at train stations, face  
authentication based payment serviceInvalid source specified.. Therefore, this paper, as the  
result of our research, aim to develop an application to detect who wearing mask or not ,  
remind all people protect themselves carefully, also figure out dataset, methodology, library  
that used and learnt from the above researchers.  
II. METHODOLODY  
A. Dataset  
The dataset used in this paper consists of ―with mask‖ and ―without mask‖ images of  
user. We will use the dataset to build a COVID-19 face mask detector with computer vision  
and deep learning. Our goal is training a custom deep learning model to detect whether a  
person is wearing a mask or not. The dataset is then split into training set and test set to serve  
for the training and test phases, respectively. The data has total 1376 observation and is clean,  
which is suitable for research purpose.  
B. Technology  
The encoder-decoder architecture has been implemented using Googles framework for  
distributed machine learning TensorFlow. We used Keras on top of TensorFlow. Keras was  
chosen as it is designed for fast prototyping and experimentation with a simple API. It allows  
to configure NNs in a modular way by combining different layers, activation functions, loss  
functions, and optimizers, etc. Keras provides out of the box solutions for most of the  
standard deep learning building blocks. However, if someone wants to build a custom or  
novel implementation, Keras API could be quite limited, and libraries like TensorFlow will be  
a better choice. Besides, we use OpenCV being an open source library for image and video  
analysis to implement our COVID-19 face mask detector in real-time video streams. For  
evaluation, different metrics have been used, that were partly taken from the scikit-learn  
library for Python.  
C.Fine-tuning with Keras and Deep Learning  
To train a classifier to automatically detect whether a person is wearing a mask or not,  
we are fine-tuning pre-trained CNN model in Keras and TensorFlow. In our project, we  
choose MobileNetV2 model for fine-tuning which is one of the highly efficient pre-trained  
CNN models.  
Regarding to fine-tuning technique, fine-tuning is a strategy which we use to establish a  
baseline model while saving considerable time. We take a scalpel and cut off the final set of  
FC layers from a pre-trained CNN (MobileNetV2), then replace the head with a new set of FC  
layers with random initializations. From there, all layers below the head are frozen so their  
weights cannot be updated. We then train the network using a very small learning rate so the  
new set of FC layers can learn patterns from the previously learned CONV layers earlier in  
the network. The way how fine-tuning works is represented in the following figure 1.  
Figure 1: The way how fine-tuning works  
Looking at figure 1, the original FC Layers are removed and replaced with a brand-new  
FC head. These FC layers can then be fine-tuned to a specific dataset (the old FC Layers are  
no longer used). Especially, in fine-tuning process, one of the vital steps which is  
constructing a new FC head and appending it to the base in place of the old head is analyzed  
more thoroughly.  
58  
To creating FC layers, we need to declare Dense layer from tensorflow.keras.layers.  
With our project, we declare two parameters in Dense including number of units in a FC layer  
and activation. Activation determines the output of a deep learning model, its accuracy, and  
the computational efficiency of training a model.  
In the above code script, the number of units of a FC layer is 128 units, and activation  
function is ReLU (Rectified Linear Unit). The ReLU is the most used activation function  
nowadays when training neural networks. ReLU simply filters values less than 0. ReLU is  
expressed by the following equation and graph.  
f(x)=max(0, x)  
ReLU is more popular because this function brings many outstanding advantages such  
as efficient computation, the faster speed of convergence.  
D. Model Evaluation Criteria  
To evaluate the performance of forecasting models, we use classification metrics  
including accuracy, precision, recall, F1-score to compare predicted values with observed  
values. Accuracy is number of instances correctly classified over the total number of  
predictions. Precision is fraction of instances correctly classified. Recall is fraction of positive  
examples in the test set that have been correctly classified and also called coverage, sensitivity  
or True Positive Rate. F1-score is a metric to balance between Precision and Recall.  
Precision = TP/(TP+FP)  
Recall = TP/(TP+FN)  
F1-score = 2 x Precision x Recall/ (Precision + Recall)  
Accuracy = (TP+TN)/N where N = TP+TN+FN+FP  
In the above equations, TP is true positive, FP is false positive, FN is false negative, TN  
is true negative. The above classification metrics values range from 0 to 1, and the larger  
these values are, the more effective the trained model is.  
III. IMPLEMENTATION  
To build a COVID-19 face mask detector, we implement main steps including data  
preprocessing, training MobileNetV2 model and detecting faces with and without masks. In  
terms of data preparation for image dataset, pre-processing steps include resizing images to  
224×224 pixels, converting to array format, and scaling the pixel intensities in the input image  
to the range [-1, 1] (via the preprocess_input function). After that, we append the pre-  
processed image and associated label to the data and labels lists, respectively and ensure that  
our training data is in NumPy array format.  
With regard to training pre-trained MobileNetV2 model, we need to prepare this model  
for fine-tuning. Fine-tuning is a strategy which we use to establish a baseline model while  
saving considerable time. Setting up fine-tuning goes through a three-step process including  
loading MobileNetV2 with pre-trained ImageNet weights, leaving off head of network and  
constructing a new FC head, and freezing the base layers of the network to not update the  
weights of these base layers during the process of backpropagation.  
60  
With our data prepared and model architecture in place for fine-tuning, we can compile  
and train our face mask detector network. Once the model is fit, we can estimate the  
performance of the model on the train and test datasets.  
To present the visualization of the predicted values and the trained ones, we use  
matplotlib library to show the comparison among them.  
Figure 2: Training loss and accuracy on COVID-19 database  
Looking at Figure 2, we can see there are little signs of overfitting, with the validation  
loss lower than the training loss. Given such high accuracy, we are hopeful that our model  
will generalize well to images outside our training and testing set. With applying trained  
model and using OpenCV library, we can implement our COVID-19 face mask detector in  
real-time video streams.  
IV. CONCLUSION AND FUTURE WORK  
Generally speaking, masked face recognition technology can be used to recognize  
people wearing masks, but it is still not very effective compared to standard facial recognition  
technology that has already seen more than 99 percent accuracy. Another related task is the  
identification of face masks, that is to recognize whether a person wears a mask as necessary  
or not. Our research has contributed to the prevention and control of coronavirus epidemics  
and the development in industry through scientific and technological support. In fact, people  
still wear masks due to the regular incidence of hazy conditions, therefore the need for face  
recognition with masks may continue for a long time in future work.  
REGERENCES  
[1] Y. W. X. L. L. R. J. Z. Y. H. L. Z. G. F. J. X. X. G. e. a. Chaolin Huang, "Clinical  
features of patients infected with 2019 novel coronavirus in Wuhan, China," The Lancet, pp.  
497-506, 2020.  
[2] M. Z. X. D. J. Q. F. G. Y. H. Y. Q. J. Nanshan Chen, "Epidemiological and clinical  
characteristics of 99 cases of 2019 novel coronavirus pneumonia in Wuhan, China: a  
descriptive study," The Lancet, pp. 507-513, 2020.  
[3] K. L. a. G. M. L. Joseph T Wu, "Nowcasting and forecasting the potential domestic  
and international spread of the 2019-nCoV outbreak originating in Wuhan, China: a  
modelling study," The Lancet, pp. 689-697, 2020.  
[4] W. Team, "World Health Organization," Advice on the use of masks in the context  
detail/advice-on-the-use-of-masks-in-the-community-during-home-care-and-in-healthcare-  
settings-in-the-context-of-the-novel-coronavirus-(2019-ncov)-outbreak.  
[5] G. L. C. L. I. F. J. M. Marian Stewart Bartlett, "Machine Learning Methods for  
Fully Automatic," in IEEE International Conference on Systems, Man and Cybernetics, San  
Diego , 2004.  
[6] M. S.-J. L. Sachin Sudhakar Farfade, "Multi-view Face Detection Using Deep  
Convolutional," 2015.  
[7] O. J. B. J.-E. V. a. M. C. RaphaeÈl FeÂraud, "A Fast and Accurate Face Detector,"  
vol. 23, pp. 42-53, 2001.  
[8] S. Daityari, "sitepoint," Face Detection and Recognition with Keras, 7 November  
[9] G. W. B. H. Z. X. Q. H. H. W. P. Y. K. J. Zhongyuan Wang, "Masked Face  
Recognition Dataset and Application," 2020.  
62  
pdf 7 trang baolam 23740 Free
Bạn đang xem tài liệu "Mask detecting program", để tải tài liệu gốc về máy hãy click vào nút Download ở trên

File đính kèm:

  • pdfmask_detecting_program.pdf