Hawkeye Vision Model: AI-enabled Mask Wearing Detection

Project Introduction

In today’s world, one of the common issues that people are facing is to remain safe while being in crowded places. This problem was exacerbated when COVID-19 struck major cities in the world, forcing city dwellers to adapt to the new norm, such as wearing masks and frequently washing hands with soap.

If we search for COVID precautions/prevention on the web, we get a list of recommendations to stay safe. One advice that frequently appears is to “wear a mask when physical/social distancing is not possible”. In this project, our team hopes to leverage artificial intelligence (AI) to help reduce the spread of COVID-19 by encouraging mask wearing and create awareness among employee in offices.

Target Problems

In certain regions, mask wearing may be compulsory for crowded places such as workspaces or in public transits. Our project aims to help teams better enforce this requirement by identifying those who do not abide to the rules, and alert teams.

This project will be used to classify those who are wearing masks and those who aren’t in offices or public places. Based on the classification report, we can find out which employees are following the rule of mask wearing in the office premises. If an employee fails to comply with these requirements, we can find out who it is and inform their respective managers and take necessary actions.

Solution

We are planning to implement the above concept by splitting it into 3 modules. The first module is to detect if a person/employee is wearing a mask or not from a webcam/video. The second module is to identify the person from the image and store the employee information such as employee id, name into a database or any file. Here we don’t have any employee records so we will use the image of celebrities found online, and map it with their name and store it in a database or file (.csv or .txt file).

For the first and second module we can use the concepts in machine learning and deep learning. The third module is to send mail to the respective employees looping their manager for necessary action. This module can be implemented using any programming language such as Python, Java, .Net, etc. An architecture and flow diagram are attached below to explain the flow briefly.

The module files are available on our Github Repo: https://github.com/VivekAnandhangithub/Alibab_Hackathon_2020

Flow Diagram of Face Mask Detection

Architecture of Face Mask Detection

Nomask Detect (Image Source: Wikipedia)

The person has a mask (Image Source: Pinkvilla)

An email with attachment from Python

Alibaba Cloud Products Used

Technology highlights

We used Alibaba AI API and Alibaba ECS to build the Machine Learning models using python language to detect the face and face mask in an image and detect the name of the person using it.

We have used the Convolutional Neural Networks (ConvNets or CNNs) in our modules to perform image recognition and classification. ConvNets have been successful in identifying faces, objects and traffic signs. There are different architectures available in CNN and we have used MobileNet and VGG models.

We have explained algorithms used in each module below.

In the first module we detect if a person/employee is wearing a mask or not from an image. We have used predefined algorithm called Haar Cascade which is used to identify objects in an image or video. There are multiple or different types of models in the Haar cascade which can be used to detect face, mask, eye, etc in an image or video. We have used haarcascade_frontalface_alt2 model and pre-defined weight to detect the face mask in an image. The model has 160 layers and Having total parameters of 2,422,210. Out of which 164,226 parameters are trainable and the remaining 2,257,984 are non-trainable parameters. We created a user defined function in that we added the logic to check if a person in an image has a mask or not based on the result a specific output is displayed. If the person in the image has no mask then it will display the image highlighting his face and it will display the confidence or accuracy of its mask prediction.

In the Second module we are trying to classify the person from the image using VGG16, model and predefined weights of VGG are used here. We are using the SVM model to predict name of the person in an image and store the predicted name in a text file. The model has a total of 145,002,878 parameters and all are used as a trainable parameter.

In Module 3 we will be sending an email to the manager with the image showing as no mask with the level of accuracy. In the webcam we will be taking the frame and storing it in a location and will be sharing it to the respective manager. Here we configured our Gmail as the domain to send email.

Future Enhancement

We are planning to implement the above concept with different/multiple kind of datasets and models. We are also planning to add another module to determine the social distancing.

About the Team

Vivekanandhan M. — Alibaba Cloud MVP — Artificial Intelligence

I’m skilled in Content Management System, Machine learning and deep learning, Web Applications, Digital Transformations, Automation and Cloud Technology Enthusiast and having 9 years of experience. I have published my Research Articles about Cloud Technology in many International Journals and Harvard University.

Koushik Radhakrishnan — Sr. Developer

I’m skilled in .Net, Python, SAS, Machine learning and deep learning, Web Applications. I am doing my PGP in AIML from Great Lakes Institution and University of Texas Austin and having 5 years of experience. Working on implementing projects related to Machine Learning and deep learning.

Disclaimer: The views and opinions expressed in this article are for reference only and do not necessarily represent those of Alibaba Cloud. Alibaba Cloud will not be liable for any false, inaccurate, inappropriate, or incomplete information presented on this article.

Alibaba Tech

First hand and in-depth information about Alibaba’s latest technology → Facebook: “Alibaba Tech”. Twitter: “AlibabaTech”.

First-hand & in-depth information about Alibaba's tech innovation in Artificial Intelligence, Big Data & Computer Engineering. Follow us on Facebook!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store