explaingit

davidsandberg/facenet

14,318PythonAudience · researcherComplexity · 4/5Setup · hard

TLDR

Face recognition system using TensorFlow that converts face photos into numeric embeddings for comparing, grouping, or identifying people, includes pre-trained models ready to use.

Mindmap

mindmap
  root((FaceNet))
    How it works
      Face embeddings
      MTCNN alignment
      Distance comparison
    Pre-trained Models
      CASIA-WebFace
      VGGFace2
    Use Cases
      Face verification
      Photo clustering
      Custom classifier
    Tech Stack
      Python
      TensorFlow
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a face verification system that checks whether two photos show the same person.

USE CASE 2

Cluster a photo collection by person identity using the numeric embeddings the model produces.

USE CASE 3

Train a custom face classifier on top of the pre-trained FaceNet model without starting from scratch.

USE CASE 4

Run the included MTCNN face detector to find and align faces in photos before passing them to another model.

Tech stack

PythonTensorFlowMTCNN

Getting it running

Difficulty · hard Time to first run · 1h+

Requires TensorFlow and a compatible GPU for practical use, pre-trained model checkpoints must be downloaded separately.

In plain English

This project is a face recognition system built with TensorFlow, Google's machine learning library. It is an implementation of a method described in a research paper called FaceNet, and it also borrows ideas from a second paper on deep face recognition from a group at Oxford. The README states the code was heavily inspired by an earlier project called OpenFace. The basic idea is to turn a photo of a face into a short list of numbers, which the field calls an embedding. The system is trained so that two photos of the same person produce number lists that are close together, while photos of different people produce lists that are far apart. Once you have these number lists, you can compare faces, group them, or build a classifier that names who is in a picture. Before a face goes into the model, the picture is cleaned up in a step called alignment. The README explains that a simpler face detector missed harder cases such as partly hidden faces or silhouettes, so the project switched to a method called MTCNN, a multi-task neural network that finds and lines up faces more reliably. A Python and TensorFlow version of MTCNN is included. The authors provide pre-trained models so you do not have to train from scratch, which would need a large dataset and a lot of computing time. Two models are listed, trained on public face datasets called CASIA-WebFace and VGGFace2, the larger of which contains roughly 3.3 million faces. On a standard benchmark named LFW, the best model reaches about 99.6 percent accuracy. The README also includes a dated news log of changes, notes on which TensorFlow versions the code was tested against, and links to wiki pages describing how to train your own classifier and how to run the validation test. It reminds users to credit the people who provided the training datasets.

Copy-paste prompts

Prompt 1
Using the davidsandberg/facenet pre-trained VGGFace2 model, compare two face photos and output a similarity score to determine if they are the same person.
Prompt 2
Show me how to use the FaceNet MTCNN aligner to detect and crop all faces from a folder of photos into separate image files.
Prompt 3
Using davidsandberg/facenet, train a face classifier that can identify 5 people from a small set of labeled training photos.
Prompt 4
How do I load the FaceNet model checkpoint and generate 512-dimension embeddings for a new face image in Python?
Open on GitHub → Explain another repo

← davidsandberg on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.