Official gitlab repository for EdgeFace: Efficient Face Recognition Model for Edge Devices published in IEEE Transactions on Biometrics, Behavior, and Identity Science.
Abstract: We present EdgeFace - a lightweight and efficient face recognition network inspired by the hybrid architecture of EdgeNeXt. By effectively combining the strengths of both CNN and Transformer models, and a low rank linear layer, EdgeFace achieves excellent face recognition performance optimized for edge devices. The proposed EdgeFace network not only maintains low computational costs and compact storage, but also achieves high face recognition accuracy, making it suitable for deployment on edge devices. The proposed EdgeFace model achieved the top ranking among models with fewer than 2M parameters in the IJCB 2023 Efficient Face Recognition Competition. Extensive experiments on challenging benchmark face datasets demonstrate the effectiveness and efficiency of EdgeFace in comparison to state-of-the-art lightweight models and deep face recognition models.
@article{george2023edgeface,
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}
}
Install dependencies of Insight face repo. You can find them here. Install DALI as well.
Install PyTorch to 2.0.0 with CUDA.
Run the following commands:
pip install timm==0.6.12
pip install pandas tabulate mxnetThe 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
arch="edgeface_base"# or "edgeface_s_gamma_05" # or edgeface_xs_gamma_06
model=get_model(arch)
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
])
checkpoint_path=f'checkpoints/{arch}.pt'
model.load_state_dict(torch.load(checkpoint_path, map_location='cpu'))
model.eval()
path = 'assets/synthface.jpeg'
aligned = align.get_aligned_face(path)
transformed_input = transform(aligned).unsqueeze(0)
embedding = model(transformed_input)
print(embedding.shape)There are two configurations in this source code. The mappings of names and method names in the results are:
- Method Name :
{name} - Idiap EdgeFace-S(𝛾=0.5) :
edgeface_s_gamma_05 - Idiap EdgeFace-XS(𝛾=0.6) :
edgeface_xs_gamma_06
To see the model parameters, flops, and size on disk, run the following commands:
python eval_edgeface.py edgeface_s_gamma_05
python eval_edgeface.py edgeface_xs_gamma_06Download and prepare WebFace4M and WebFace12M: place the .rec files in data/webface4m and data/webface12m. You can find more instructions here.
Launch the following command after setting the root path and output path in the config files:
torchrun --nproc_per_node=8 train_v2.py configs/edgeface_s_gamma_05.pyAfter finishing this step, launch:
torchrun --nproc_per_node=8 train_v2_restart.py configs/edgeface_s_gamma_05_restart.pyLaunch the following command after setting the root path and output path in the config files:
torchrun --nproc_per_node=4 train_v2.py configs/edgeface_xs_gamma_06.pyAfter finishing this step, launch:
torchrun --nproc_per_node=4 train_v2_restart.py configs/edgeface_xs_gamma_06_restart.pyedgeface_baseedgeface_xs_gamma_06edgeface_xs_qedgeface_xxsedgeface_xxs_qedgeface_s_gamma_05
You can load the models using torch.hub as follows:
import torch
variant='edgeface_xs_gamma_06'
model = torch.hub.load('otroshi/edgeface', variant, source='github', pretrained=True)
model.eval()
> :warning: **Note About the License:** Please refer to the `LICENSE` file in the parent directory for information about the license terms and conditions.