Face Detection webApp

Bernardo Caldas
Analytics Vidhya
Published in
3 min readOct 25, 2020

--

In this quick post I wanted to share a very popular way to deploy your model as webApp using Streamlit.io

“ Face detection is a computer technology being used in a variety of applications that identifies human faces in digital images.[1] Face detection also refers to the psychological process by which humans locate and attend to faces in a visual scene.” — https://en.wikipedia.org/wiki/Face_detection

Formally, Face Recognition is defined as the problem of identifying or verifying faces in an image. How exactly do we recognize a face in an image?

Face recognition can be divided into multiple steps. The image below shows an example of a face recognition pipeline.

  1. Face detection — Detecting one or more faces in an image.
  2. Feature extraction — Extracting the most important features from an image of the face.
  3. Face classification — Classifying the face based on extracted features.
sample face detection

There are various ways to implement each of the steps in a face recognition pipeline. In this post we’ll focus on popular deep learning approaches where we perform face detection using MTCNN, feature extraction using FaceNet and classification using Softmax. — https://arsfutura.com/magazine/face-recognition-with-facenet-and-mtcnn/

MTCNN

Implementation of the MTCNN face detector for Keras in Python3.4+. It is written from scratch, using as a reference the implementation of MTCNN from David Sandberg (FaceNet’s MTCNN) in Facenet. It is based on the paper Zhang, K et al. (2016) [ZHANG2016].

source = https://pypi.org/project/mtcnn/

>>> from mtcnn import MTCNN
>>> import cv2
>>>
>>> img = cv2.cvtColor(cv2.imread("ivan.jpg"), cv2.COLOR_BGR2RGB)
>>> detector = MTCNN()
>>> detector.detect_faces(img)
[
{
'box': [277, 90, 48, 63],
'keypoints':
{
'nose': (303, 131),
'mouth_right': (313, 141),
'right_eye': (314, 114),
'left_eye': (291, 117),
'mouth_left': (296, 143)
},
'confidence': 0.99851983785629272
}
]
MTCNN output sample

Deploy the webApp

Deploying a model simply means into an existing production environment which can take in an input and return an output that can be used in making practical business decisions. Here is where Streamlit comes to play !

follow the webapp, feel free to test ;-)

write rectangle in images

follow the webapp, feel free to test ;-)

Youtube video tutorial

--

--

Bernardo Caldas
Analytics Vidhya

Developer | AI | Driving innovation with development tools and AI. Making technology meaningful