Face Mask Detection Openvino

Detect faces and determine whether people are wearing mask.

AI & Machine LearningPythonGPL-3.0

Abstract

Face Mask Detection Openvino is an open-source AI & Machine Learning project. Detect faces and determine whether people are wearing mask. Face Mask Detection application uses Deep Learning/Machine Learning to recognize if a user is not wearing a mask and issues an alert. It is built using Python, Deep Learning. The complete source code is publicly available on GitHub under the GNU General Public License v3.0, making it a useful reference for students building an AI & Machine Learning mini project or final-year project.

1. Introduction

Face Mask Detection application uses Deep Learning/Machine Learning to recognize if a user is not wearing a mask and issues an alert.

This application executes 2 parallel infer requests for the Face Mask Detection and Face Detection networks that run simultaneously.

By utilizing pre-trained models and Intel OpenVINO toolkit with OpenCV. This enables us to use the async API which can improve overall frame-rate of the application, rather than wait for inference to complete, the application can continue operating on the host while accelerator is busy.

2. Objective

Detect faces and determine whether people are wearing mask.

This project demonstrates how Python, Deep Learning can be applied to a real-world AI & Machine Learning problem.

4. Technology Stack

PythonDeep Learning
  • Minimum Intel Gen 6 processors

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Python 3.8 or later
  • pip / virtualenv for dependencies
  • VS Code, PyCharm or Jupyter Notebook
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/mmphego/face_mask_detection_openvino.git
cd face_mask_detection_openvino
  1. Download the docker images with a pre-installed version of OpenVINO 2020.2
  2. Download the facemask detection model.
  3. Convert model to OpenVINO's Intermediate Representations (IR) using the Model Optimizer, which will produce .xml and .bin files.
  4. Download face detection model from the model zoo, which will produce .xml and .bin files.
docker pull mmphego/intel-openvino
wget https://github.com/didi/maskdetection/raw/master/model/face_mask.caffemodel
wget https://raw.githubusercontent.com/didi/maskdetection/master/model/deploy.prototxt
docker run --rm -ti \
--volume "$PWD":/app \
--env DISPLAY=$DISPLAY \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
mmphego/intel-openvino \
bash -c "/opt/intel/openvino/deployment_tools/model_optimizer/mo.py \
    --framework caffe \
    --input_model face_mask.caffemodel \
    --input_proto deploy.prototxt"
docker run --rm -ti \
--volume "$PWD":/app \
--env DISPLAY=$DISPLAY \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
mmphego/intel-openvino \
bash -c "/opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py \
    --name face-detection-adas-0001 \
    --precision FP16"

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Deploy the model as a web app with Streamlit, Flask or FastAPI
  • Compare against an additional model and report the metric difference
  • Add explainability (SHAP / Grad-CAM)

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. What dataset does the project use and how was it pre-processed?
  2. Which algorithm / model architecture is used and why was it chosen over alternatives?
  3. How are training and testing data split, and how is overfitting avoided?
  4. Which evaluation metrics (accuracy, precision, recall, F1) are reported and what do they mean here?
  5. How would you deploy this model for real users?

9. Source Code & License

This project is developed by mmphego and published on GitHub under the GNU General Public License v3.0. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on an AI & Machine Learning project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for AI & Machine Learning Internship