Last update: 10 December 2019
The way facial recognition systems works is as follows:
First, you feed the image to a neural network that detects and localizes the face. Then you pass the cropped face to a second neural network that encodes it in a vector in a high dimensional space.
In order to recognize the same person from another image, you follow these steps to calculate the representation vector. Then you measure the similarity between these two vectors using this similarity equation:
Finally, you define a
threshold. If the similarity is bellow that threshold, then it's the same person otherwise it's a different person.
To see this in practice, I created a web app that lets you play with this.
$ git clone https://github.com/pythops/facial_recognition_app $ cd facial_recognition_app
$ virtualenv --prompt=facial_recognition_app venv $ source venv/bin/activate $ pip install -r requirements.txt
$ flask run
These are some examples where you see that the system recognizes well Elon Musk.