Find this example on our SD-image
This is a fast C++ implementation of two deep learning models found in the public domain.
The first is face detector of Linzaer running on a ncnn framework.
https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB.
The second is the Paddle Lite mask detection which classifies the found faces.
https://github.com/PaddlePaddle/Paddle-Lite/tree/develop/lite/demo/cxx/mask_detection.
The frame rate depends on the number of detected faces and can be calculated as follows:
FPS = 1.0/(0.04 + 0.01 x #Faces) when overclocked to 1950 MHz.
Paper: https://arxiv.org/abs/1905.00641.pdf
Size: 320x320
Special made for a bare Raspberry Pi see Q-engineering deep learning examples
A new and superior version with only TensorFlow Lite for a bare Raspberry Pi see GitHub
To run the application, you have to:
- A raspberry Pi 4 with a 64-bit operating system. It can be the Raspberry 64-bit OS, or Ubuntu 18.04 / 20.04. Install 64-bit OS
- The Paddle Lite framework installed. Install Paddle
- The Tencent ncnn framework installed. Install ncnn
- OpenCV 64 bit installed. Install OpenCV 4.5
- Code::Blocks installed. (
$ sudo apt-get install codeblocks
)
To extract and run the network in Code::Blocks
$ mkdir MyDir
$ cd MyDir
$ wget https://github.com/Qengineering/Face-Mask-Detection-Raspberry-Pi-64-bits/archive/refs/heads/master.zip
$ unzip -j master.zip
Remove master.zip and README.md as they are no longer needed.
$ rm master.zip
$ rm README.md
Your MyDir folder must now look like this:
Face_1.jpg
Face_2.jpg
Face_3.jpg
Face_Mask_Video.mp4
MaskUltra.cpb
mask_ultra.cpp
UltraFace.cpp
UltraFace.hpp
RFB-320.bin
RFB-320.param
slim_320.bin
slim_320.param
The RFB-320 model recognizes slightly more faces than slim_320 at the expense of a little bit of speed. It is up to you.
Note that the compilation of the Paddle Lite framework in your application can take minutes (> 3 min).
See the video at https://youtu.be/LDPXgJv3wAk