How face recognition works: embeddings, thresholds and why you never store faces

Detection, alignment, embedding and matching explained without the maths, plus how to choose a similarity threshold, handle false matches, and design storage so a breach leaks numbers, not faces.

Taking questions during a session
Taking questions during a session

Face recognition is four steps, and only one of them is recognition. Understanding the pipeline is what lets you build one responsibly — which for FaceVision meant a system where the server has never seen a face.

The four steps

  1. Detection — find faces in the frame and return bounding boxes and landmarks.
  2. Alignment — rotate and crop each face to a canonical pose using the landmarks, so the next model sees consistent input.
  3. Embedding — a recognition model maps the aligned face to a vector, typically 128 to 512 numbers, such that the same person's faces land close together.
  4. Matching — compare the new embedding to stored ones with cosine similarity and decide with a threshold.

Choosing the threshold

Too strict and real users are rejected; too loose and strangers get in. Collect a small labelled set — pairs of the same person, pairs of different people — and plot the similarity distributions. The threshold sits where the curves separate; where they overlap is your error rate, and you should state it. Lighting, glasses and age change the distribution, so test with your actual users, not a benchmark.

Why you store embeddings, never images

An embedding is enough to verify a person and useless for showing anyone what they look like. Storing only embeddings — the FaceVision design — means a database breach leaks vectors rather than faces, consent conversations get simpler, and deletion is a single row. Run detection and embedding in the browser with ONNX Runtime Web and the raw image never leaves the device at all (see running ML models in the browser).

Failure modes to design for

  • A printed photo held up to the camera — this is why liveness detection exists.
  • Twins and look-alikes — accept that similarity is not identity and add a second factor for high-stakes actions.
  • Bias — recognition models perform unevenly across skin tones and ages; measure per group before deployment.

Build it this way and you can explain your system to a privacy officer in two sentences. That is a competitive advantage, not just an ethical one.

Face recognitionEmbeddingsPrivacyComputer vision
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · Kanpur, Uttar Pradesh, India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU Kanpur) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. Email pranjulrathour41@gmail.com.

Keep reading

More on Vision & speech

All Vision & speech posts →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.

Pranjul Rathour, GenAI engineer in Kanpur