face-recognition

Face-Recognition Training Framework

Downloads GitHub Repo stars GitHub Repository GitHub License


๐Ÿ”ฅ Updates


๐Ÿ“Š Results

Dataset Backbone LFW (%) CALFW (%) CPLFW (%) AgeDB_30 (%) Num Params
MS1MV2 Sphere20 99.67 95.61 88.75 96.58 24.5M
MS1MV2 Sphere36 99.72 95.64 89.92 96.83 34.6M
MS1MV2 MobileNetV1_0.25 98.76 92.02 82.37 90.02 0.36M
MS1MV2 MobileNetV2 99.55 94.87 86.89 95.16 2.29M
MS1MV2 MobileNetV3_Small 99.30 93.77 85.29 92.79 1.25M
MS1MV2 MobileNetV3_Large 99.53 94.56 86.79 95.13 3.52M

โœจ Features

Date Feature Description
2024-12-15 ๐Ÿ”„ Training Pipeline: Introduced a simple and effective pipeline for face-recognition training with support for DDP and single GPU configurations.
2024-12-15 ๐Ÿ“š Pretrained Models: Added support for MobileNetV1/V2/V3, Sphere20, and Sphere36 models for versatile use-cases and performance tiers.
2024-12-15 ๐Ÿ“‚ Dataset Downloads: Easy access to aligned and cropped training and validation datasets via Kaggle links.
2024-12-15 ๐Ÿ”ง Modular Codebase: Fully modular and reproducible codebase for easier customization and extension.
2024-12-15 ๐ŸŒ Dataset Compatibility: Supports CASIA-WebFace, VGGFace2, and MS1MV2 datasets, pre-aligned and cropped for streamlined training.

๐Ÿš€ Getting Started

๐Ÿ’ป Installation

git clone https://github.com/yakhyo/face-recognition.git
cd face-recognition
pip install -r requirements.txt

๐Ÿ‹๏ธโ€โ™‚๏ธ Training

Codebase supports DDP, to run using DDP please use below example command:

torchrun --nproc_per_node=2 train.py --root data/train/ms1m_112x112 --database MS1M --network mobilenetv1 --classifier MCP

If you have a single GPU then use the below example command:

python train.py --root data/train/ms1m_112x112 --database MS1M --network mobilenetv1 --classifier MCP

๐Ÿงช Evaluate

To evaluate, please modify model, weights, and validation data filenames in evaluate.py

python evaluate.py

๐Ÿ“ฅ Pretrained Model Weights (v0.0.1)

The following pretrained model weights are available for download under the release v0.0.1:

Model Download Link
MobileNetV1_0.25 Download
MobileNetV2 Download
MobileNetV3_Small Download
MobileNetV3_Large Download
Sphere20 Download
Sphere36 Download

๐Ÿ”ง Usage

  1. Download the model weights from the links above.
  2. Place the weights in the desired directory (e.g., weights/).
  3. Update your training or inference script to load the appropriate model weights.

ONNX Export

Run following command to export to ONNX:

python -m scripts.onnx_export -w [path/to/weight/file] -n [network/architecture/name] --dynamic[Optional]

ONNX Inference

Run onnx_inference.py to use ONNXRuntime. This inference calculates the similarity between two face images.

python onnx_inference.py

PyTorch Inference

Run inference.py for PyTorch model inference. This inference calculates the similarity between two face images.


๐Ÿ“‚ Dataset

You can download aligned and cropped (112x112) training and validation datasets from Kaggle.

๐Ÿ“ฆ Training Data

๐Ÿ” Validation Data

Validation data contains AgeDB_30, CALFW, CPLFW, and LFW datasets.


๐Ÿ—‚๏ธ Folder Structure

data/
|-- train/
|   |-- ms1m_112x112/
|   |-- vggface2_112x112/
|   |-- webface_112x112/
|-- val/
|   |-- agedb_30_112x112/
|   |-- calfw_112x112/
|   |-- cplfw_112x112/
|   |-- lfw_112x112/
|   |-- agedb_30_ann.txt
|   |-- calfw_ann.txt
|   |-- cplfw_ann.txt
|   |-- lfw_ann.txt

๐Ÿ“ License

This project is licensed under the MIT License. See the LICENSE file for details.