This blog post was originally published at Xailient’s website. It is reprinted here with the permission of Xailient.
Face detector is one of the most commonly used AI component today. Whether you are building a system to count the number of people in a room or a home security system that unlocks the door when you reach your front door, you need a face detector.
Given an image, a Face detector locates the faces present in the image and gives coordinates of each face present in the image.
There are tons of face detectors that are available, and honestly, it might be quite overwhelming for you to decide which one would be best for your project. There is no one right answer.
The choice of Face Detector depends on the requirements of your project such as available resource and target inference speed.
In this post, I will do a comparison of the four cutting edge Face detectors that are available today: OpenCV Haar Cascade, Xailient, Dlib and MTCNN. I will also give code for each of the Face detectors so you can either repeat the comparison or can use as a kick-starter for your project.
Face Detector Comparison
For the comparison between OpenCV Haar Cascade, Xailient, Dlib and MTCNN Face detectors, I used a Raspberry Pi 3B+, with Raspbian Buster as the operating system. Test Videos used for this experiments were downloaded from Pexels.com
Here are the video links:
Here’s a video of comparison results for the four Face Detectors.
Below are the scripts I used for running each of the Face detectors.
OpenCV Haar Cascade
To setup, install the required python libraries using pip command.
pip3 install opencv-python
I used OpenCV version 4.1.0 for this experiment.
Here is the code for Face detection using OpenCV Haar Cascade:
Dlib
To setup, install the required python libraries using pip command.
pip3 install dlib
pip3 install opencv-python
pip3 install imutils
I used OpenCV version 4.1.0 for this experiment.
Here is the code for Face detection using Dlib:
Xailient
To setup, install the required python libraries using pip command.
pip3 install opencv-python
pip3 install numpy
I used OpenCV version 4.1.0 for this experiment.
To install Xailient Face detector, follow these instructions.
Here is the code for Face detection using Xailient:
MTCNN
To setup, install the required python libraries using pip command.
pip3 install opencv-python
pip3 install mtcnn
pip3 install tensorflow
I used OpenCV version 4.1.0 for this experiment.
Here is the code for Face detection using MTCNN:
Comparison Results
Here’s the list of the Face detectors in descending order of their performance (best is on the top of the list):
- Xailient Face Detector
- OpenCV Haar Cascade Face Detector
- Dlib Face Detector
- MTCNN Face Detector
Xailient ran 16 times faster than OpenCV Haar Cascade Face detector using only 1/4 the resources with better qualitative accuracy.
Xailient ran 80 times faster than Dlib Face detector using the same amount of resources with similar qualitative accuracy.
Xailient ran 80 times faster than MTCNN Face detector using only 1/4 the resources with similar qualitative accuracy.
Download Xailient Face Detector today from Xailient Console.
Sabina Pokhrel
Customer Success AI Engineer, Xailient