Today we are in a world where we don't know if a person is smiling or frowning!!! Masks have become an integral part of our living and rightly so, as they help us in curbing the spread of the virus. Of course you remember March 2020, when Corona hit India. The virus spread rapidly due to which several lockdown measures were imposed and people were asked to wear masks and maintain social distancing.
But why am I reiterating these precautions? Have you noticed that even though wearing of masks is mandatory, several people wear masks in the wrong way(exposing their noses for a fresh breeze of air!!!) or even worse, don't wear masks at all!
That's when I began thinking if there was a way to solve this problem.
Machine Learning and Object Detection to the rescue
A couple of months ago I had trained a machine learning model to detect drones. This made me think if the same technique could be used to solve the problem of mask detection, because at the end of the day both were objects! I started searching for the source files of the drone detector but was disappointed not to find them. This meant starting all over by writing the code from scratch!
A blessing in disguise
I was not too happy to start from scratch but it was a blessing in disguise as it helped me discover the latest version of YOLO, YOLOv4 which was much faster and more accurate than the earlier version(YOLOv3) used in the drone detection model. This meant that the mask detector would be far more accurate than the drone detector.
Machine Learning in simple words is teaching a machine to do human-like tasks. These tasks could vary from driving cars and understanding speech to recommending cat videos on YouTube and detecting masks! Just like a baby can distinguish between a ship and a car only after seeing their images, a machine learning model also requires a lot of data before it can make accurate predictions. The mask detector would need images of:
1. People wearing masks
2. People not wearing masks or wearing them incorrectly.
I downloaded these freely available images on Google. This was however not enough and that's when my friends and family helped me by sharing their own images with and without masks. After collecting this data, the model finally began training. With a hundred errors and staring at the computer screen for days, the model had finally finished training.
To test the model, I needed help of some actors, namely - my parents and my brother:) The video below shows the results of this testing:
Next Steps: Real Life Scenarios
My neighbour is helping me integrate this model with CCTV cameras so that it would help identify people wearing masks incorrectly or not wearing masks at all thus helping curb the spread of the virus.
PS: If you think YOLO is You Only Live Once, think again! The YOLO model actually stands for You Only Look Once:)
Hope you enjoyed reading! Do wear your mask properly and stay safe!