All You Need to Know about Face Mask Detector for Preventing COVID-19 Spread

Author

Ruchir Kakkad

27 May 2020

7 min

Coronavirus outbreak has claimed over 95000 lives in the US alone. The world is still struggling against this pandemic without any vaccine or a powerful drug. The old saying ‘Prevention is better than cure’ holds true in this grim situation. Globally, many governments have imposed lockdown to restrict movements for preventing the spread of this dreaded disease. All countries want to make their citizens ready to follow social distancing to avoid contamination.

Face masks have proven an effective tool to prevent the spread of COVID-19 to date. People tend to use them while going out and try to avoid any infection through mouth and nose. However, it is still observed in many regions that many people have not made face masks a part of their life yet. When millions of people’s lives could be at stake due to this pandemic, it is necessary for the authorities to detect people who do not wear face masks.

But, here is a catch! Finding people without face masks is like looking for a needle in a haystack. Thankfully, technology comes to our rescue through the face mask detector.

In this article, we are trying to explain how to implement a COVID-19 face mask detector with Keras and Pytorch’s convolutional neural network.

Here it is fair to mention that the face mask detector is not the only thing technology can do. According to the current situation, several technological advancements are used to reduce the burden of the Government. For example, drones help to catch up with the people who break the lockdown, the thermal camera measures the temperature of the humans and detects the fever. These devices work wonders in imposing strict regulations to curb the spread of coronavirus.

Face Mask detectors are also helpful at different places where many people gather daily. These detectors are worked on the basis of  AI (Artificial Intelligence) technology. Let’s discuss how the face mask detector works to find out people without masks.

How does Face Mask Detector Work?

without mask person

Figure 1: A Person without Mask

person with mask

Figure 2: A Person with Mask

As shown in Figures 1 and 2, we can easily mark the difference between a person without a mask and a person with a mask. The face mask detector gives the results in the same way.

A smart, AI-powered COVID-19 face mask detector can detect the face mask in two ways:

  1. Detect face masks by using images
  2. Detect face masks in video-streaming

Let’s understand the complete workflow of face mask detectors. 

Workflow

Flowchart-01

Figure 3: Steps to build COVID-19 Face Mask detector

As you can see in Figure 3,  we have predefined steps in order to run the face mask detector. First of all, we gather our dataset and divide it into two folders. One is With Mask and another one is Without Mask. This is a typical way through which the AI technology works. Neural networks can learn through the dataset and start making decisions by themselves.

Then we have given our Dataset to the Pytorch’s convolutional neural network model. This model serialized the given dataset like in which property it should fall into, for example- Which persons are masked and which are not masked. After that, we train our model on the given dataset. Once the model is trained, we test it with testing images and videos.

Dataset

We used RMFD(Real-World-Masked-Face-Dataset) dataset to achieve the objective of this face mask detector.

This dataset consists of Total 1,665 Images which are divided into 2 categories:

  1. With Mask – containing 865 images
  2. Without Mask – containing 800 images

So by having this amount of dataset we tried to train the neural network model to detect whether a person is wearing a mask or not.

Here is the image containing masked and unmasked people. We have taken this image for making the neural model understand the difference between people with masks and without masks.

Our face mask detection dataset examples

Mask and unmask

Figure 4: Masked and Unmasked Dataset

As you can see, figure 4 shows the images used for training. We even used multiple images of people as well.

Our Approach

Our approach was to train a small classifier on some intermediate feature map of a pre-trained model. The advantages of this method are two-fold- a small training dataset is required, and it yields a multi-task model that has a minor increased computational cost compared to the original single-task model. For instance, we added a single layer to our face recognition model to detect face masks. As a result, the model, at the inference time, is used to recognize faces and tell whether the person is wearing a mask.

A subset of images is held out from the training phase used to test the performance. The model trained on around 1600 images and after 70 epochs, it achieves an impressive accuracy on the test set.

Accuracy

Training Loss and accuracy on covid-19 dataset
Figure 5: Graph of Loss and Accuracy

Now comes the most important part- the accuracy of the results. Looking at Figure 5, we can see there are little signs of overfitting, with the validation loss is less than the training loss. We have achieved around 99% accuracy in this face mask detection with very little training loss. There is no exaggeration in mentioning that this face mask detector can effectively detect the persons without masks anywhere and anytime.

Wrapping Up

We are sailing through troubled waters. Even a small step taken against the COVID-19 pandemic can make a big difference. This is the right time to work together to defeat this invisible enemy of humankind. Futuristic technologies like AI can help us curb the spread by providing us face mask detector. Let’s try to minimize the impact of coronavirus outbreak on our life and society by using advanced solutions.

CTA -face mask detect

At WebOccult, we strive to make innovative software solutions using cutting-edge tools and technologies. Our enterprise-grade solutions can drive the growth of your business by simplifying complexities and bringing automation. Let’s connect through sending an email at info@localhost. Our business consultants will contact you shortly to give your company an edge during the corona age.

Categories
  • AI/ML
  • Web Development
  • Laravel
  • Computer Vision
  • Mobile App Development
  • Digital Twin
Subscribe To Our Newsletter

Subscribe to our newsletter and receive a selection of cool articles every weeks