Facial Recognition

Timucin Erbas
Analytics Vidhya
Published in
5 min readDec 19, 2020

--

Something we all take for granted is being able to identify someone using their face. Seeing your friend from the front, left or right — it doesn’t matter, you still can understand who they are.

Can computers do this?

Simple answer, yes! Long answer — Its a bit complicated…

How It Works

Facial Recognition has 4 fundamental steps to it:
- Face Boxing
- Feature Boxing
- Important point selection
- Absolute Distance Vectorization
- Vectoral Classification

Face Boxing

In this step of the process, we want to box only the person’s face in the image since everything else in the picture is irrelevant to us.

We can box someone’s face in by putting the 2 dimentional picture through a Convolutional Neural Network. After all of the forward propagation, this specific Neural Network would output 4 values. 2 pairs of 2, the first pair being the coordinates of the upper left corner of our “box” and the second pair being the lower right corner of the box.

With these 4 coordinate values we know which portion of the image is relevant to us.

Feature Boxing

Once we get a snippet of the face, we “box” the features of the face itself. This is not a concrete rule, you can make your own list of what features you want to box. Most commonly, the list includes:
- Eyes
- Mouth
- Ears
- Nose

So for the sake of simplicity, lets use those features. We design convolutional neural networks similar to the “face boxing” neural network, to box in the specific features.

Important Point Selection

Once we have all of the facial features in a box, we select important points on the person’s face. “But what do you mean by important points?” I hear you ask.

Important points can be the middle of the nostrils, ends of the mouth, pupil, top of the ears… You get it.

In order to select these important points, we use the boxes that the previous step had created. Since the boxes highlight important areas of the face, we can select points within those boxes, which would mean those points are “important points”

Usually the points selected on those boxes are the corners and the exact middle of the boxes that they are in.

Now these points might seem pretty random, but they will resemble something in the end.

Absolute Distance Vectorization

When the points are selected, we take the distance in between the points. These distances can be betwen every possible pair, or the 5 closest ones. That is a matter for you to choose when writing the algorithm. We can represent these distances as lines.

We did’t use a specific algorithm to connect the dots above, however, at the end, this is the network of lines that represents this guy’s face (according to my “algorithm”).

Once we have the network of lines we measure how long each one is and we put it in an array/vector. A vector is basically a list of numbers.

When you think about it, this is amazing. We just converted a face of a person into a list of numbers!

Vectorial Classification

Now that we have the numbers for each person’s face, we have to know how the computer can classify someone. How does it know that 2 pictures of Amy are both Amy even though the list of numbers for each picture are not exactly the same?

To figure this out, lets say we have 3 pictures of Jeff, 3 pictures of Bill and 3 pictures of Elon, all converted into numbers.

When we graph the vectors of each image, Elon’s, Jeff’s and Bill’s vectors will all be in their similar cluster since similar faces give similar numbers.

Now we give a new image of a person. If this is a different person, this image will be plotted away from the other clusters telling the algorithm it is a different person since the coordinates of the image is so far away from any other cluster.

However if we give another picture that is an image of Elon, then that point will be close to Elon’s cluster telling the algorithm that it is Elon’s picture.

And there you have it folks! Machines knowing who a human is 😱 I hope this article has given you what you have been looking for, and that you have liked it. If you enjoy my articles, I highly reccomend subscribing to my newsletter as I send out monthly updates on what I have been up to :)

Monthly Newsletter ✏️ https://mailchi.mp/02ac433cc6eb/subscribe-timucin-erbas

Later! 👋

--

--

Timucin Erbas
Analytics Vidhya

Leveraging AI and Space Technology to shape the future