Real-Time Face Re-Identification with FAISS, ArcFace & SCRFD

February 16, 2026 · View on GitHub

Downloads GitHub Repo Stars GitHub Repository DeepWiki

Tip

The models and functionality in this repository are integrated into UniFace — an all-in-one face analysis library.
PyPI Version GitHub Stars License

Key Features

  • Real-Time Face Recognition: Process webcam or video files with SCRFD detection and ArcFace embeddings
  • FAISS Similarity Search: Batch cosine-similarity lookup using a FAISS inner-product index
  • Multiple Model Sizes: Choose from lightweight to high-accuracy detection and recognition models
  • Minimal Dependencies: Built on ONNX Runtime, OpenCV, NumPy, and FAISS with no extra frameworks

Note

Place your target face images in the assets/faces/ directory. The filenames will be used as identity labels during recognition.

Components

  1. SCRFD — Sample and Computation Redistribution for Efficient Face Detection
  2. ArcFace — Additive Angular Margin Loss for Deep Face Recognition
  3. FAISS — Facebook AI Similarity Search

Available Models

CategoryModelSizeDescription
DetectionSCRFD 500M2.41 MBLightweight face detection
DetectionSCRFD 2.5G3.14 MBBalanced performance
DetectionSCRFD 10G16.1 MBHigh accuracy
RecognitionArcFace MobileFace12.99 MBMobile-friendly recognition
RecognitionArcFace ResNet-50166 MBHigh-accuracy recognition

Project Structure

├── assets/
│   ├── demo.mp4
│   ├── in_video.mp4
│   └── faces/              # Place target face images here
│       ├── face1.jpg
│       ├── face2.jpg
│       └── ...
├── database/               # FAISS database implementation
├── models/                 # Neural network models
├── weights/                # Model weights (download required)
├── utils/                  # Helper functions
├── main.py                 # Main application entry
└── requirements.txt        # Dependencies

Getting Started

Prerequisites

Important

Make sure you have Python 3.10+ installed on your system.

Installation

  1. Clone the repository:
git clone https://github.com/yakhyo/face-reidentification.git
cd face-reidentification
  1. Install dependencies:
pip install -r requirements.txt
  1. Download model weights:
Click to see download links 📥
ModelDownload LinkSize
SCRFD 500Mdet_500m.onnx2.41 MB
SCRFD 2.5Gdet_2.5g.onnx3.14 MB
SCRFD 10Gdet_10g.onnx16.1 MB
ArcFace MobileFacew600k_mbf.onnx12.99 MB
ArcFace ResNet-50w600k_r50.onnx166 MB

Quick download (Linux/Mac):

sh download.sh
  1. Add target faces: Place face images in assets/faces/ directory. The filename will be used as the person's identity.

Usage

Basic Usage

python main.py --source assets/in_video.mp4

Command Line Arguments

Tip

Use these arguments to customize the recognition behavior:

usage: main.py [-h] [--det-weight DET_WEIGHT] [--rec-weight REC_WEIGHT]
               [--similarity-thresh SIMILARITY_THRESH] [--confidence-thresh CONFIDENCE_THRESH]
               [--faces-dir FACES_DIR] [--source SOURCE] [--max-num MAX_NUM]
ArgumentDescriptionDefault
--det-weightDetection model path./weights/det_10g.onnx
--rec-weightRecognition model path./weights/w600k_mbf.onnx
--similarity-threshFace similarity threshold0.4
--confidence-threshDetection confidence threshold0.5
--faces-dirTarget faces directory./assets/faces
--sourceVideo source (file or camera index)./assets/in_video.mp4
--max-numMax faces per frame (0 = unlimited)0
--db-pathCustom database storage location./database/face_database
--update-dbForce rebuild face databaseFalse
--outputSpecify output video pathoutput_video.mp4

Technical Notes

  • Face database is saved to and loaded from disk automatically; no rebuild needed on restart
  • All detected faces in a frame are queried in a single FAISS index.search() call
  • For GPU-accelerated inference, install onnxruntime-gpu instead of onnxruntime

References

Note

This project builds upon the following research:

  1. SCRFD: Sample and Computation Redistribution for Efficient Face Detection
  2. ArcFace: Additive Angular Margin Loss for Deep Face Recognition