PythOps

simple facial recognition system

Last update: 10 December 2019

Basics of facial recognition systems

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.

Setup

  1. Clone the app from github
$ git clone https://github.com/pythops/facial_recognition_app
$ cd facial_recognition_app
  1. Install the dependencies
$ virtualenv --prompt=facial_recognition_app venv
$ source venv/bin/activate
$ pip install -r requirements.txt
  1. Run the app
$ flask run
  1. Open this link http://127.0.0.1:5000 in your browser and upload your own set of photos.

Examples

These are some examples where you see that the system recognizes well Elon Musk.

Recommended reading