Mask detection using Deep Learning

Mask detection using Deep Learning

In this article I’m explaining how to make computer vision deep learning based mask detection.

 

Before you start to read this article, I recommend watching my video first. If you are interested how I created this deep learning based mask detection program, just keep on reading this article.

 

Data set for mask detection

Data set is the first and the most important part of this application. I asked my friend and my familly to send me two images, one with mask on and one without it. To make the algorithm, I used the best 14 images. Hovewer, more good quality images in the data set should always give you better final result.

 

Data set for mask detection

 

There are many types of masks used to protect ourselfs from COVID19 and this example shows it perfectly. Each participant had a different mask. This is a key piece of the puzzle, because if I would like to use this application in real cases, I would need many more images with different masks to increase system reliability. At the end of this part I add some of my images to the test set, which were not included in deep learning training process.

 

Used deep learning algorithm

 

To make this mask detection application I used Instance Segmentation  algorithm from Adaptive Vision. This deep learning approach is used to locate, segment and classify single or multiple objects within an image. In this case, the advantage of this technique compared to others, such as Classification or Feature Detection, is that instance segmentation detects individual objects and may be able to separate them even if they touch or overlap.

instance_segmentation_before

Original image. Source

instance_segmentation_results

Visualized instance segmentation results. Source

However, this technique has also a few disadvantages. As opposed to Adaptive Vision’s  Feature Detection algorithm, this one requires images with constant dimensions. Furthermore, in my opinion, Instance Segmentation technique is less accurate than Feature Detection.

Hardware setting

Of course, before I loaded the collected data set, I had to scale the images to the size of the target video. Images used in this video were made using smartphones. However, because of the architecture of the software used, the target application can only use industrial cameras or webcams. In this presentation I decided to use video previously recorded on the smartphone due to its quality. I could also use web camera or industrial camera to achieve the same effect. As a hardware unit for calculations I used gaming notebook with 7th gen Intel i7 CPU and GTX 1050 Ti GPU.

Deep learning model

After that, I was able to load all images and train the deep learning model. I have created two classes: „Mask” and No_mask”. Then, I marked all training images with instances of created classes.

No_mask class

„No_mask” class

Mask class

„Mask” class

I haven’t changed region of interest in training image set, however, it could be a little narrow. I have changed default training parameters. The key to success of this application was to set a large enough number of augmentations. As you saw in the video, the deep learning model training lasted one hour.

deep learning parameters

Training parameters

Mas detection in the Adaptive Vision Studio

Created deep learning segment instances model is compatible with Adaptive Vision Studio software. Main program is divided into three parts:

  • Acquisition part – in this case, ReadVideo function has been used.
  • Deep learning model – DeepLearning_SegmentInstances has been used.
  • Drawing results  – I cereated visualization from available blocks and I made macrofilter from them. For visualization I used Adaptive Vision Studio’s previews, but it is also possible to create HMI.
Main program

Main program.

draw results macrofilter

„Draw results” macrofilter.

Summary and conclusions

As a summary, I would like to point out the most important part of each headline:

  • In my option, proper data set is the most important aspect of this application. More (good quality) images  in the data set should always give you the best final result.
  • For this program I chose deep learning Instance Segmentation technique.
  • Images and recordings from smartphones were used to prepare this video and article. However, in the real application I recommend using industrial camera.
  • To create deep learning model, I created two classes. The key to success of this application was  to set a large enough number of augmentations.
  • Whole application has been made in Adaptive Vision Studio software.

 

Deep learning based mask detection is only one of many ways how machine vision could help with ongoing fight with COVID19. In this article I wrote about other possibilities, but it is still not all we can do. I saw many other amazing applications, like measuring and inspecting the distance between people.

 

I hope you enjoyed 🙂 If you would still like to get more information about presented solution, just contact me via e-mail: admin@mvexperts.com or contact Adaptive Vision support: support@adaptive-vision.com

admin
3 komentarze

Post a Comment

Comment
Name
Email
Website