Skip to content

yakhyo/face-reidentification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

Downloads GitHub Repo stars GitHub Repository

demo.mp4

This repository implements face re-identification using SCRFD for face detection and ArcFace for face recognition. It supports inference from webcam or video sources.

Features

  • FAISS Vector Database Integration: Enables fast and scalable face re-identification using a FAISS index built from facial embeddings. Faces must be placed in the assets/faces/ directory.
  • Smaller versions of SCFRD face detection model has been added
  • Face Detection: Utilizes Sample and Computation Redistribution for Efficient Face Detection (SCRFD) for efficient and accurate face detection.
    • Added models: SCRFD 500M (2.41 MB), SCRFD 2.5G (3.14 MB)
  • Face Recognition: Employs ArcFace: Additive Angular Margin Loss for Deep Face Recognition for robust face recognition.
    • Added models: ArcFace MobileFace (12.99 MB)
  • Real-Time Inference: Supports both webcam and video file input for real-time processing.

Project folder structure:

β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ demo.mp4
β”‚   |── in_video.mp4
|   └── faces/
β”‚     β”œβ”€β”€ face1.jpg
β”‚     β”œβ”€β”€ face2.jpg
β”‚     └── ...
β”œβ”€β”€ database/
|   β”œβ”€β”€ __init__.py
|   └── face_db.py
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ scrfd.py
β”‚   └── arcface.py
β”œβ”€β”€ weights/
β”‚   β”œβ”€β”€ det_10g.onnx
β”‚   β”œβ”€β”€ det_2.5g.onnx
β”‚   β”œβ”€β”€ det_500m.onnx
β”‚   β”œβ”€β”€ w600k_r50.onnx
β”‚   └── w600k_mbf.onnx
β”œβ”€β”€ utils/
|   β”œβ”€β”€ logging.py
β”‚   └── helpers.py
β”œβ”€β”€ main.py
β”œβ”€β”€ README.md
└── requirements.txt

Installation

  1. Clone the repository:
git clone https://github.com/yakyo/face-reidentification.git
cd face-reidentification
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Download weight files:

    a) Download weights from following links:

    Model Weights Size Type
    SCRFD 500M det_500m.onnx 2.41 MB Face Detection
    SCRFD 2.5G det_2.5g.onnx 3.14 MB Face Detection
    SCRFD 10G det_10g.onnx 16.1 MB Face Detection
    ArcFace MobileFace w600k_mbf.onnx 12.99 MB Face Recognition
    ArcFace ResNet-50 w600k_r50.onnx 166 MB Face Recognition

    b) Run below command to download weights to weights directory (linux):

    sh download.sh
  2. Put target faces into assets/faces folder

faces/
    β”œβ”€β”€ name1.jpg
    β”œβ”€β”€ name2.jpg

Those file names will be displayed while real-time inference.

Usage

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

main.py arguments:

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]

Face Detection-and-Recognition

options:
  -h, --help            show this help message and exit
  --det-weight DET_WEIGHT
                        Path to detection model
  --rec-weight REC_WEIGHT
                        Path to recognition model
  --similarity-thresh SIMILARITY_THRESH
                        Similarity threshold between faces
  --confidence-thresh CONFIDENCE_THRESH
                        Confidence threshold for face detection
  --faces-dir FACES_DIR
                        Path to faces stored dir
  --source SOURCE       Video file or video camera source. i.e 0 - webcam
  --max-num MAX_NUM     Maximum number of face detections from a frame

Reference

  1. https://github.com/deepinsight/insightface/tree/master/detection/scrfd
  2. https://github.com/deepinsight/insightface/tree/master/recognition/arcface_torch

About

πŸ‘€πŸ”„ | Face re-identification using FAISS, ArcFace & SCRFD | ONNX Runtime Inference

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published