This repository contain inference code and pretrained models to use EdgeFace: Efficient Face Recognition Model for Edge Devices, which is the winning entry in the compact track of "EFaR 2023: Efficient Face Recognition Competition" organised at the IEEE International Joint Conference on Biometrics (IJCB) 2023. For the complete source code of training and evaluation, please check the official repository.
$ pip install -r requirements.txt
The following code shows how to use the model for inference:
import torch from torchvision import transforms from face_alignment import align from backbones import get_model # load model model_name="edgeface_s_gamma_05" # or edgeface_xs_gamma_06 model=get_model(model_name) checkpoint_path=f'checkpoints/{arch}.pt' model.load_state_dict(torch.load(checkpoint_path, map_location='cpu')).eval() transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]), ]) path = 'path_to_face_image' aligned = align.get_aligned_face(path) # align face transformed_input = transform(aligned) # preprocessing # extract embedding embedding = model(transformed_input)
- EdgeFace-s (gamma=0.5): available in
checkpoints/edgeface_s_gamma_05.pt - EdgeFace-xs (gamma=0.6): available in
checkpoints/edgeface_xs_gamma_06.pt - and more models available in
checkpointsdirectory.
The performance of each model is reported in Table 2 of the paper:
edgeface_baseedgeface_s_gamma_05edgeface_xs_qedgeface_xs_gamma_06edgeface_xxsedgeface_xxs_q
NOTE: Models with _q are quantised and require less storage.
You can load the models using torch.hub as follows:
import torch model = torch.hub.load('otroshi/edgeface', 'edgeface_xs_gamma_06', source='github', pretrained=True) model.eval()
| Model | MPARAMS | MFLOPs | LFW(%) | CALFW(%) | CPLFW(%) | CFP-FP(%) | AgeDB30(%) |
|---|---|---|---|---|---|---|---|
| edgeface_base | 18.23 | 1398.83 | 99.83 ± 0.24 | 96.07 ± 1.03 | 93.75 ± 1.16 | 97.01 ± 0.94 | 97.60 ± 0.70 |
| edgeface_s_gamma_05 | 3.65 | 306.12 | 99.78 ± 0.27 | 95.55 ± 1.05 | 92.48 ± 1.42 | 95.74 ± 1.09 | 97.03 ± 0.85 |
| edgeface_xs_gamma_06 | 1.77 | 154.00 | 99.73 ± 0.35 | 95.28 ± 1.37 | 91.58 ± 1.42 | 94.71 ± 1.07 | 96.08 ± 0.95 |
| edgeface_xxs | 1.24 | 94.72 | 99.57 ± 0.33 | 94.83 ± 0.98 | 90.27 ± 0.93 | 93.63 ± 0.99 | 94.92 ± 1.15 |
If you use this repository, please cite the following paper, which is published in the IEEE Transactions on Biometrics, Behavior, and Identity Science (IEEE T-BIOM). The PDF version of the paper is available as pre-print on arxiv. The complete source code for reproducing all experiments in the paper (including training and evaluation) is also publicly available in the official repository.
@article{edgeface, title={Edgeface: Efficient face recognition model for edge devices}, author={George, Anjith and Ecabert, Christophe and Shahreza, Hatef Otroshi and Kotwal, Ketan and Marcel, Sebastien}, journal={IEEE Transactions on Biometrics, Behavior, and Identity Science}, year={2024} }