facenet-pytorch is a PyTorch library that provides pretrained face detection and facial recognition models.
The library addresses the need for efficient face detection and recognition by combining two key components. It includes an Inception Resnet V1 model pretrained on VGGFace2 and CASIA-Webface datasets for facial recognition, with model weights ported from an established TensorFlow implementation. For the detection stage, it provides a PyTorch implementation of MTCNN that the documentation describes as the fastest available, allowing faces to be located and cropped before recognition inference. Both models are pretrained and automatically downloaded and cached on first use, requiring only instantiation to begin processing images.
Developers should adopt this tool if they need a complete face detection and recognition pipeline in PyTorch with minimal setup. The library suits projects requiring facial identification, face tracking in video streams, or fine-tuning on custom datasets. The pretrained models work best on 160x160 pixel images and perform optimally when faces are cropped using the included MTCNN detector. The tool can output either 512-dimensional embeddings for recognition tasks or classification logits when enabled, providing flexibility for different use cases.
The project maintains active engagement with its codebase through regular updates and documentation improvements. Example notebooks covering complete detection and recognition pipelines, video-based face tracking, model fine-tuning, and performance comparisons are provided to guide users through common workflows. The repository includes detailed implementation guides for both MTCNN and the recognition models, along with documentation of the parameter conversion process from the original TensorFlow implementation.