Face detection using deep learning under 5-minutes 😋

Multi-Task Cascaded Convolutional Neural Network to detect human faces.

Nan-u
2 min readJul 27, 2021

I have embarked on a journey to learn deep learning. “For the things we have to learn before we can do them, we learn by doing them.” — Aristotle.

Face detection using deep learning is a famous problem. There are already many exemplary pre-trained model architectures available to detect human faces in an image. Hence, we skip the training or transfer learning stage. We will be using one such architecture, “Multi-Task Cascaded Convolutional Neural Network” MTCNN.

First, we download images from Flickr. These images serve as input to the MTCNN model to detect faces. Then we import the images in our Python file and call MTCNN.detect_faces.

That’s it. Now, the faces array contains a list of all faces that MTCNN detected in our image.

Print output of faces array

The above images show the different attributes of each face detected, and we have x, y coordinates, and dimensions of the face in box[x, y, width, height] attribute. In addition, we also have the confidence score of MTCNN and other landmark features such as mouth, eyes, and nose.

We can now draw the bounding boxes over our image to have visual confirmation about how well our MTCNN model performs to detect faces.

MTCNN detected bounding boxes overlapped on input image

Tada 🎉 We have our face detection code. How well the model performs varies from image to image. There are many other alternative models available, and we can always plug better models and experiment to see if we get better results.

--

--