03

Deep Scan — Facial Recognition System

A complete system combining an embedding database with FAISS-optimised search: the face is detected with MTCNN, encoded into a vector by InceptionResNetV1 (FaceNet), then the closest matches to a query are retrieved in milliseconds.

Real-time vector search

Stack

PythonFAISSFaceNetStreamlit

What happened?

  1. 01

    The question

    When I was little, I was fascinated by how my mom's phone recognized her face and told it apart from mine. Then I started doing AI and I got my little hunch. So I decided to recreate the system. So the question is: can you build a complete recognition system robust enough to identify a person from their face alone, without manually labelling every image, and resilient to lighting and position changes?

  2. 02

    The problem

    Comparing pixels is fragile: lighting, angle and expression change everything. And naively comparing one face against thousands of others quickly becomes too slow. AI exists to make our lives easier. (Thanks, CNNs)

  3. 03

    The hypothesis

    I figured that through one process or another we should be able to store a digital version of each face (an embedding vector). Then we could do the same to a face we want to identify. Add a distance metric and we're done. The problem reduces to a nearest-neighbour search in a vector space.

  4. 04

    The build

    A pipeline: MTCNN detection -> InceptionResNetV1 encoding (FaceNet) -> FAISS indexing. A Streamlit interface to register a face and run a query. Embeddings are persisted.

  5. 05

    The failure

    A few problems at first: a streaming mode that glitched in my browser, and my face — which was supposed to be detected — kept matching someone else's. Pfff... I also had to handle the database synchronization (where I used a very original method).

  6. 06

    The discovery

    Once the face is centred and normalized, euclidean distances are the best choice and FAISS finds the right person. You have to load the vectors into memory only once, to avoid reloading on every new query. And even with glasses on, the system stays stable.

  7. 07

    The result

    A working system: register an individual, compute their embedding, and return the closest matches to a query in real time.

  8. 08

    The next frontier

    Detecting impostors (similarity threshold), moving to more robust models (ArcFace), and handling millions of faces with FAISS quantization.

Spider-Verse · homage