Human With mask or Without mask?

Nupur Manglic
5 min readJul 8, 2020

--

Coronavirus disease of 2019 (COVID-19) caused by the novel coronavirus “Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-COV-2)” has catastrophic implications on mankind. COVID-19 virus transmits through droplet (5–10 m in diameter), some scientists also suspected about airborne transmission. Transmission of the virus can occur by direct contact with an infected person or by through fomites in the immediate environment around the infected person.

It is said that “Prevention is better than cure.” So as a preventive measure of COVID-19 wearing a facemask is the easiest way to stop transmission. It is evident from the literature that wearing a facemask may reduce the amount of emission of infected saliva and respiratory droplets, thus help in COVID-19 control [1]. Knowing the importance of wearing a facemask, many countries have made wearing facemask mandatory. Despite the importance of wearing facemask some people still don’t wear a facemask. It is very important to find a system to keep surveillance on people wearing and not wearing a mask.

Objective

The major objective of this project is to detect people wearing masks (images/ live streaming) using Convolutional Neural Networks (CNNs)

Introduction

This type of model is based on a simple way to identify faces, including facial features through technology, like deep learning [5]. It extracts facial features and classifies them in different categories. The system can also be utilized to send an alert message to the authorized person if someone has entered the premises without a face mask. Moreover, the data can be transferred and stored automatically in the system to enable reports whenever you want. In this study, we proposed a CNN based model to detect faces with masks and without masks. The model is robust and can predict the accuracy of 91.06%

Methodology

Experimental Environment

Fig 1: Project Overview

The Dataset

A diverse dataset consisting of 2348 images of people from all age groups and races is created by downloading images from google by using image downloader extension.

The final dataset consists of 1174 images of Face with mask and 1174 Face without a mask. All the images labeled 0 faces with mask 1 faces without a mask.

All the images were converted into grayscale, resized, and rescaled by utilizing NumPy utility.

Fig 2(a): Sample images used in the dataset Color images

Fig 2(b): Sample images used in the dataset greyscale images

Model Building

Convolutional neural networks (CNNs) are a class of deep neural networks, which are widely used in pattern and image/video recognition problems. CNN has several advantages compared to other neural networks such as they can work with image data in 2D. It takes an image in the form of an array of numbers. CNN consists of multiple layers (convolution and subsampling) optionally followed by a fully connected layer. The code used to build the model is shown in fig 2. We used CNN bet cause of its accuracy, flexibility and does not require feature extraction.

Fig 3: Flow Chart of CNN

Fig 4: Code used to build the model

The model summary looks like

Fig 5: Model Summary Training and Testing

Parameters used to build CNN model

The model was trained and tested in Jupyter Notebook Environment, which provides a very user friendly interface to work on.

Training and Testing

The built model has testing accuracy is 91.06%. We make the network go through 50 epochs. Model is also evaluated based on F1 score, recall, precision, accuracy, and loss curve.

As Explained in Keras Q/A the terms training loss and testing loss corresponds to the metrics that show improvements in the model. Higher the loss is worse the model accuracy.

Confusion Matrix

A confusion matrix is a synopsis of predictions that results in a classification problem. The number of right and wrong predictions are summarized with count values and broken down by each of the particular class. This is the value point for the confusion matrix. The confusion matrix also predicts the methods in which our classification model is confused when it makes predictions. It gives us perception not only into the errors being made by a classifier but more importantly the various types of errors that are made.

Results Achieved

•The proposed network was trained and tested on the dataset and achieved an accuracy of 91.06%.

  • With the precision (positively predicted value) as 0.91 and recall (sensitivity) as 0.91.
  • Sum of diagonals of the confusion matrix equals to 214 which means out of 235 values 214 is correctly classified which results out with the accuracy of 91.06%.
  • Therefore, the CNN model has a good accuracy to classify human with and without masks

for more details

https://youtu.be/S8t_g2i81n8

References

The role of community-wide wearing of face mask for control of coronavirus disease 2019 (COVID-19) epidemic due to SARS-CoV-2. Journal of Infection.

https://www.leewayhertz.com/face-mask-detection-system/

https://github.com/chandrikadeb7/Face-Mask-Detection/

https://www.pyimagesearch.com/2020/05/04/covid-19-face-mask-detector-with-opencv-keras-tensorflow-and-deep-learning/

It was fun working on this model and learning the concepts of CNN to analyze images. If you liked this blog or have some feedback or followup questions please comment.

Thanks for Reading!

Favors to

Abhishekgupta, AYUSH RAGHUWANSHI, Anish Vaidya, Harshita Tiwari, Samyuktha S

--

--