wprazuch / face-mask-detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Face Mask Detection

Face-mask-detection

This repository contains a project devoted to detect face masks in the images. The solution is composed of two steps - first, a face detector (pretrained Caffe model, downloaded from here) recognizes faces in the image and draws bounding boxes around them. Next, these bounding boxes are cropped from the image and passed sequentially to the classification model, trained in binary mode. The classifier checks, whether the person in the image wears a mask or not. This way, the system can spot people in the image with masks and without masks.

Data

Part of the data used for classification was reused from there and there. The test images were collected from the web and used for visualization purposes and debugging.

Methods

The solution was implemented mainly by using OpenCV and Tensorflow libraries. As stated previously, for face detection, a pretrained model based on ResNet architecture was used. For classification, a MobileNet V2 architecture available from Keras API was used and trained.

To train a classification model, use: python train.py

To check all the optional arguments, use: python train.py -h

By default, the script will save the model to models/face-mask-classifier directory.

This app can be launched in Docker. To set it up, simply run a following command from the root directory of the repo:

docker build -t facemask -f docker/development.dockerfile .

To launch the Flask server on port 5000, run:

docker run -p 5000:5000  facemask python -m server.app

Next steps

The solution could be extended to the video-mode. This application would be useful in real-world, as the system could be embedded into supervision cameras, which will notify about persons not wearing masks (and i.e. entering a building).

Endnote

Feel free to check my other projects on my Github Pages Site.

About


Languages

Language:Jupyter Notebook 94.6%Language:Python 5.4%Language:Dockerfile 0.1%