Facial Recognition Attendance System
Tags: Deep Learning, Face Recognition, Face Net, Convolution Neural Net, Reactjs

“The face is a picture of the mind with the eyes as its interpreter.”

― Marcus Tullius Cicero

Facial recognition is a modern-day technique capable of identifying a person from its digital image. They work by comparing selected facial features from a person with faces it knows from training. It is a biometric identification that analyzes facial features to give accurate results from a given image.

In this project, a complete end to end solution for regular attendance using face recognition and identification is provided.

The work is divided into 2 main parts:

1.Facial Recognition and identification.

2.REST API for server and other requirements.

1.Facial Recognition and Identification.

Facial Recognition starts from face extraction from a given image cropping out the background for one or more faces found in the image. It separates actual faces from its background and makes it easier for the recognition task. For the process of the face identification we have different methods. In this blog, I am talking about using the dlib library

I am implementing dlib for face detection, which uses a combination of HOG (Histogram of Oriented Gradient) & Support Vector Machine (SVM). The model is trained on Positive and Negative images with an anchor image. (Positive image means the same person and negative image means a different person)

In this project, I am using the OpenFace pre-trained model for face embedding. OpenFace used FaceNet(Google’s model used on 3D images) architecture on isolated faces by dlib library.

OpenFace uses a simple 2D affine transformation to make the eyes and nose appear in similar locations for the neural network input. The 68 landmarks are detected with dlib’s face landmark detector. Given an input face, the affine transformation makes the eye corners and nose close to the mean locations. The affine transformation also resizes and crops the image to the edges of the landmarks so the input image to the neural network is 96 × 96 pixels.

FaceNet uses the Triplet loss function on the given input image to identify and make embedding more accurate and reliable.

One way to learn the parameters of the neural network so that it gives you a valid encoding for your pictures of faces is to define an applied gradient descent on the triplet loss function. To apply the triplet loss, we need to compare pairs of images. Given a picture, to learn the parameters of the neural network, we have to look at several pictures at the same time. For example, given a pair of images of the same person, we want their encodings to be similar. Whereas, given a pair of images of different persons, we want their encodings to be quite different. In the terminology of the triplet loss, what we are going do is always look at one anchor image, and then we want to distance between the anchor and the positive image to be smaller. Whereas, we want the distance to be much further apart when the anchor is compared to the negative example. So, this gives rise to the term triplet loss, in which we will be looking at three images at a time, A positive, a negative, and an Anchor image.

The dataset used for training purpose consists of 10 images of each person with different angles, for more precision and to avoid any ambiguity. Dataset is divided into 70:30 as training and validation dataset respectively.