Skip to content

About

HyperFace (ICLR 2025): face recognition trained only on synthetic identities, MIT weights | PyTorch & ONNX Runtime Inference

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

HyperFace: Generating Synthetic Face Recognition Datasets by Exploring Face Embedding Hypersphere

Downloads License: MIT

ONNX Runtime inference for HyperFace (ICLR 2025, Idiap Research Institute), a face recognition model trained only on synthetic identities, with face detection from UniFace.

Models

Model Training data LFW CPLFW CALFW CFP AgeDB Size ONNX PyTorch
IR-50 HyperFace 50k (3.2M synthetic images) 98.27 85.60 91.48 92.24 90.40 166 MB Link Link

Accuracy figures are Idiap's, from the model card of HyperFace-50k-StyleGAN.

Weight port

Idiap published the model as a PyTorch training checkpoint. The weights here are ported from that file into a plain state dict, and the ONNX is exported from it:

Idiap .ckpt  ->  backbone state dict (.pt)  ->  onnx_export.py  ->  shipped .onnx

The PyTorch weights give the same output as Idiap's checkpoint, and the ONNX agrees to within 1e-6 on the embedding, checked on 96 real faces.

Installation

pip install -r requirements.txt
bash download.sh  # Download model weights

Needs Python 3.11 or newer.

Demo

Face verification

Usage

CLI

python main.py assets/img1.jpeg assets/img2.jpeg

Python API

from models import FaceRecognition

fr = FaceRecognition()
similarity = fr.compare('assets/img1.jpeg', 'assets/img2.jpeg')
is_same = fr.is_match('assets/img1.jpeg', 'assets/img2.jpeg', threshold=0.3)

Faces are detected with UniFace's RetinaFace. Pass detector= to use another UniFace detector.

The default threshold is 0.3, which gave 98.4% accuracy on the 1,000 LFW test pairs.

PyTorch and export

models/backbones.py holds the IResNet-50 as a plain nn.Module.

pip install torch onnx
python onnx_export.py                                           # .pt -> .onnx
python onnx_export.py --checkpoint HyperFace_50k_StyleGAN.ckpt  # start from Idiap's file

The network follows the AdaFace code base the model was trained with. It differs from InsightFace's IResNet-50 in two layers, so InsightFace weights do not load into it.

Notes

  • Input is an aligned 112x112 face in BGR order, scaled to [-1, 1].
  • The output is already L2-normalised.
  • "Synthetic" describes the training images. The pipeline that generated them uses a pretrained face recognition model and a face generator.
  • Idiap also released 10k-identity checkpoints. They export the same way.

Reference

License

MIT

About

HyperFace (ICLR 2025): face recognition trained only on synthetic identities, MIT weights | PyTorch & ONNX Runtime Inference

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages