ONNX Runtime inference for HyperFace (ICLR 2025, Idiap Research Institute), a face recognition model trained only on synthetic identities, with face detection from UniFace.
| 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.
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.
pip install -r requirements.txt
bash download.sh # Download model weightsNeeds Python 3.11 or newer.
python main.py assets/img1.jpeg assets/img2.jpegfrom 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.
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 fileThe 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.
- 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.
- HyperFace: project page and paper, with the training code
- AdaFace: the training code base and network definition
- UniFace: face detection and alignment
