Face-Mask Detection using Keras

1 0
  • 0 Collaborators

In this project, we are going to see how to train a COVID-19 face mask detector with Keras, and Deep Learning. I'm using Python Script to train a face mask detector The script additionally is divided into two parts: 1. Detect COVID-19 face masks from image 2. Detect face masks in real-time video ...learn more

Project status: Published/In Market

Artificial Intelligence

Intel Technologies
Intel Python

Code Samples [1]

Overview / Usage

In order to effectively prevent the spread of COVID19 virus, almost everyone wears a mask during coronavirus epidemic. This almost makes conventional facial recognition technology ineffective in many cases, such as community access control, face access control, facial attendance, facial security checks at train stations, etc. Therefore, it is very urgent to improve the recognition performance of the existing face recognition technology on the masked faces. Most current advanced face recognition approaches are designed based on deep learning, which depend on a large number of face samples.

In this project, we’ll discuss our two-phase COVID-19 face mask detector, detailing how our computer vision/deep learning pipeline will be implemented. From there, we’ll review the dataset we’ll be using to train our custom face mask detector. I’ll then show you how to implement a Python script to train a face mask detector on our dataset using Keras and TensorFlow. We’ll use this Python script to train a face mask detector and review the results. Given the trained COVID-19 face mask detector, we’ll proceed to implement two more additional Python scripts used to Detect face masks in real-time video streams.We’ll wrap up the post by looking at the results of applying our face mask detector. I’ll also provide some additional suggestions for further improvement.

Methodology / Approach

In order to use facial marks to construct a data set of facial masks, we need to begin with an image of a person who does not wear a facial mask:

  • We apply face detection from there to calculate the location of the bounding box in the image
  • Once we know where in the image the face is, we can extract the face Region of Interest (ROI), and from there, we apply facial landmarks, allowing us to localize mouth, face, and eyes.
  • In order to apply masks, we need an image of a mask (with a transparent and high definition image). Add the mask to the detected face and then resize and rotate, placing it on the face.
  • Repeat this process for all input images
  1. **Training: **Train the mask and without mask images with an appropriate algorithm.
  2. Deployment: Once the models are trained, then move on the loading mask detector, perform face detection, then classify each face.

Once an image has been uploaded, the classification happens automatically. It is then possible to apply some interpretability methods for neural network understanding. The UI presents two of the following methods:

  • Grad CAM: it visualizes how parts of the input image affect a CNN output by looking into the activation maps.
  • Occlusion Sensitivity: it visualizes how parts of the input image affect a CNN confidence by iteratively occluding parts

Technologies Used

The main technologies used in this project includes Python and Machine learning using Keras and Tensorflow.

Python libraries/Dependencies used in projects-

from tensorflow.keras.preprocessing.image import ImageDataGenerator

from tensorflow.keras.applications import MobileNetV2

from tensorflow.keras.layers import AveragePooling2D

from tensorflow.keras.layers import Dropout

from tensorflow.keras.layers import Flatten

from tensorflow.keras.layers import Dense

from tensorflow.keras.layers import Input

from tensorflow.keras.models import Model

from tensorflow.keras.optimizers import Adam

from tensorflow.keras.applications.mobilenet_v2 import preprocess_input

from tensorflow.keras.preprocessing.image import img_to_array

from tensorflow.keras.preprocessing.image import load_img

from tensorflow.keras.utils import to_categorical

from sklearn.preprocessing import LabelBinarizer

from sklearn.model_selection import train_test_split

from sklearn.metrics import classification_report

from imutils import paths

import matplotlib.pyplot as plt

import numpy as np

import argparse import os

Repository

https://github.com/Tanvesh-11/Face-Mask-Detection

Comments (0)