Skip to content

A simple Streamlit frontend for a pre-trained MobileNet CNN model + OpenCV for face mask detection in images.

Notifications You must be signed in to change notification settings

virtualramblas/streamlit-face-mask-detector

Repository files navigation

streamlit-face-mask-detector

A simple Streamlit frontend for face mask detection in images using a pre-trained Keras CNN model + OpenCV and model interpretability.
alt text

General info

This example has been implemented as part of my evaluation of the Streamlit framework. It uses OpenCV to detect faces in the input images and a CNN as mask/no-mask binary classifier applied to the face ROI. The Deep Learning model currently used has the architecture suggested by Adrian Rosebrock here and has been trained using this image data set. The trained model has been shared in this repo. The face detector algorithm comes from here: the Caffe model and its descriptor are into the face_detector directory.

Deep Learning Explanation

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 buttons to apply 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.

Usage

After cloning this repository you need to create a virtual environment and install the application dependencies
pip install -r requirements.txt
Then you can execute the application through the streamlit command
streamlit run st_face_mask_detector_expl.py
Here's a demo video:
Face Detector demo

About

A simple Streamlit frontend for a pre-trained MobileNet CNN model + OpenCV for face mask detection in images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages