Machine Learning on Facial Recognition

Image result for facial recognition

In machine learning, a Convolutional Neural Network (CNN or ConvNet) is a class of deep, feed-forward artificial neural networks that has successfully been applied to analyzing visual imagery. They have applications in image recognition (facial recognition) and video analysis, recommender systems and natural language processing. Here, facial recognition would be analysed.

What is Facial Recognition?

Facial recognition is a biometric software application capable of uniquely identifying or verifying a person by comparing and analyzing patterns based on the person’s facial contours. Facial recognition is mostly used for security purposes, though there is increasing interest in other areas of use. In fact, facial recognition technology has received significant attention as it has potential for a wide range of application related to law enforcement as well as other enterprises.

There are different facial recognition techniques in use, such as the generalized matching face detection method and the adaptive regional blend matching method. Most facial recognition systems function based on the different nodal points on a human face. The values measured against the variable associated with points of a person’s face help in uniquely identifying or verifying the person. With this technique, applications can use data captured from faces and can accurately and quickly identify target individuals. Facial recognition techniques are quickly evolving with new approaches such as 3-D modeling, helping to overcome issues with existing techniques.

There are many advantages associated with facial recognition. Compared to other biometric techniques, facial recognition is of a non-contact nature. Face images can be captured from a distance and can be analyzed without ever requiring any interaction with the user/person. As a result, no user can successfully imitate another person. Facial recognition can serve as an excellent security measure for time tracking and attendance. Facial recognition is also cheap technology as there is less processing involved, like in other biometric techniques.

How to Use Machine Learning on Facial Recognition

The approach we are going to use for facial recognition is very straight forward but you could check this out in the case of a very complicated problem. Let’s learn how modern face recognition works!

The goal here is to get deep neural network to output a person’s face with identification. This means that the neural network needs to be trained to automatically identify different features of a face and calculate numbers based on that. The output of the neural network can be thought of as an identifier for a particular person’s face — if you pass in different images of the same person, the output of the neural network will be very similar or close, whereas if you pass in images of a different person, the output will be very different.

Machine learning has solved many problems by choosing one machine learning algorithm, feeding in data, and getting the result. We do not need to build our own neural network. We have access to a trained model dlib that can be used. It does exactly what we need it to do — outputs a bunch of numbers (face encodings) when we pass in the image of someone’s face; comparing face encodings of faces from different images will tell us if someone’s face matches with anyone we have images of.

However, a facial recognition library called face recognition is much easier to install and use. This would be use at some point here.

These are the steps we will be taking:

  1. Detect: Find faces in pictures
  2. Landmark: Find and manipulate facial features in pictures
  3. Compare: Identify faces in pictures

Steps on Facial Recognition

  1. Preparing images

Here, one image will be used for simplicity.

  1. Landmark

Manipulations are done in the image by getting the locations and outlines of each person’s eyes, nose, mouth and chin.

import face_recognition
image = face_recognition.load_image_file("your_file.jpg")
face_landmarks_list = face_recognition.face_landmarks(image)

Getting output from facial recognition is a little bit tedious and facial recognition features should be considered important to analyse.

  1. Identify faces in the pictures

This is done by recognizing the faces of who appear in a photo.

import face_recognition
known_image = face_recognition.load_image_file("biden.jpg")
unknown_image = face_recognition.load_image_file("unknown.jpg")

biden_encoding = face_recognition.face_encodings(known_image)[0]
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
results = face_recognition.compare_faces([biden_encoding], unknown_encoding)

This outputs “Joe Biden” as the person in the photo.

The approach could also be used for several images in one photo and this is done by picking out faces appearing in the photo. Then the steps listed above are used to analyse the input of (n) to give outputs of (n).

Conclusion

We have been able to detect who the image represents in the photo using a simple approach by detecting, manipulating and identifying the contours of the face.

This clearly shows how machine learning has rapidly taken charge in the world of artificial intelligence. A day-to-day sample is Facebook, which automatically tags people found in a photo without tagging them manually. This was not achieved sometimes ago rather people in photos were tagged with suggestions.