Face Recognition Using Face Verification

Gokulakrishnan
Analytics Vidhya
Published in
5 min readJun 4, 2020

--

So what is Face recognition?

An automatic face recognition system is a technology capable of identifying or verifying an individual from a digital image or a video frame from a video source. There are multiple methods based on which face recognition systems work, but generally, they work by comparing selected countenance from a given image with faces within a database.

Challenges in Face recognition

Even though the development of many algorithms, still there are many challenges like

1.Pose Variation

2.Facial expression changes.

3.Ageing of the face

4.Varying lighting conditions

I want you to get excited as today we will be learning to develop a face recognition system using a face verification.

But wait, what does face verification mean? How is that different from face recognition?

Let’s first understand what is face verification, then let’s see how we can build a face recognition system from face verification.

Face Verification vs Face Recognition

Face verification is concerned with validating a claimed identity based on the image of a face, and either accepting or rejecting the identity claim. (one-to-one matching)

Face recognition may be a general topic that has both face identification and face verification that looks at facial points and contours to analyze and compare to make the attestation of like-ness.

Is it still confusing? Okay, let me explain.

For example, consider in case of checking the identity in airports they use face verification, for blocking the integrity of the person. (verify whether or not the input image is that of the claimed person.) In case of facial recognition, consider a security system for automatic door opening in the home or offices; they match the input image with the database, which may contain 100+ images per person.

I think you got it!!! Right, okay, let’s see how to build a face recognition system using face verification.

To build a face recognition system, we need some amount of data for training our neural network. Higher the data more the efficiency of the system. In conditions like this, we are building a face recognition system for a company with a minimum of 500 workers. In that case, you cannot make the workers sit and capture photos for a dataset. Again as we need more data, it is impossible to capture about 1000 or two thousand pictures of every worker. So this is our first problem with face recognition, Insufficient data; this problem is also called One Short Learning. For many face recognition applications, you would like to be ready to recognize an individual given only one image or given only one example of that person’s face. Now let’s say someone shows up at the office and wants to be made through the door despite seeing the one example of the person the system has to recognize him as the same person. So in the problem of one-shot learning, the model should be capable of identifying known and unknown persons with the help of a single example of that particular person. So, this is a classification problem. Right!! Generally, in case of classification problem, we do it just by training the Convolution Neural Network with the image data and getting the out probability through the softmax unit at the end of the network. But in this case, that’s not possible as we have a minimal number of datasets. Even if you trained the neural network with the available dataset, what happens if someone new has to join the company. In that case, you have to train the neural network with the new people dataset. That doesn’t look like a good approach.

So what are we going to do?

We can construct a similarity function instead of training the neural network with this low number of datasets. Okay, next,

what is the similarity function?

The similarity function is just a function that compares two images and returns the dissimilarity score between the two images. So if the degree of similarity between two images is low means, then they are the same person and different person, if it is high. To use similarity function for face recognition, we have to calculate a dissimilarity score for every image in the database with the input image pairwise. If all the scores have a higher value, then the person is unknown. Even if you want to add another person to the database, the same process can be done. That’s it. In this case, we have to implement the similarity function in such a way that the similarity score generated by this should be more accurate. So, for creating a similarity function, we are going to use the Siamese Network. A Siamese neural network (sometimes called a twin neural network) is a human-made neural network that uses an equivalent weight while working in tandem on two different input vectors to compute comparable output vectors. Often one among the output vectors is precomputed, thus forming a baseline against which the opposite output vector is compared. This is almost like comparing fingerprints but is often described more technically as a distance function for locality-sensitive hashing.

One way to learn the parameters of the neural network so that it gives you a good encoding for your pictures of faces is to define an applied gradient descent on the triplet loss function.
Triplet loss is a loss function for artificial neural networks where a baseline (anchor) input is compared to a positive (truthy) input and a negative (falsy) input. The distance from the baseline (anchor) input to the positive (truthy) input is minimized, and the distance from the baseline (anchor) input to the negative (falsy) input is maximized.
Florian Schroff, from Google introduced Triplet loss in their 2015 paper titled “FaceNet: A Unified Embedding for Face Recognition and Clustering.”

Triplet Loss

Upon calculating the triplet loss, we can set some threshold and verify the known and unknown persons bases on that threshold.
This approach is used as the basis behind the Face Net system that achieved then state-of-the-art results on benchmark face recognition datasets.

Summary

In this post, we discovered some challenges of face recognition and how triplet loss functions can be used to learn high-quality face embeddings. Hope you find this post an interesting one. Thank you and have nice machine learning journey.

--

--