File size: 8,510 Bytes
52017b6
 
 
 
 
 
 
 
 
 
 
 
 
 
37c841b
 
52017b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37c841b
52017b6
 
 
 
 
 
 
 
 
b2a3eb8
52017b6
37c841b
 
 
 
 
 
 
 
 
 
2944a63
 
 
 
 
 
37c841b
 
2944a63
 
 
 
 
 
 
 
 
 
37c841b
2944a63
 
 
37c841b
 
2944a63
37c841b
2944a63
 
 
37c841b
 
 
52017b6
 
 
 
 
 
37c841b
 
 
 
 
52017b6
37c841b
52017b6
 
 
 
 
 
b2a3eb8
 
 
 
 
 
52017b6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
license: cc-by-nc-sa-4.0
---


# EdgeFace-Base

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. Our EdgeFace model with 1.77M parameters achieves state of the art results on LFW (99.73%), IJB-B (92.67%), and IJB-C (94.85%), outperforming other efficient models with larger computational complexities. The code to replicate the experiments will be made available publicly.


## Overview

* **Training**: EdgeFace-Base was trained on [Webface260M](https://www.face-benchmark.org/) dataset (12M and 4M subsets)
* **Parameters**: 18.23M
* **Task**: Efficient Face Recognition Model for Edge Devices
* **Framework**: Pytorch
* **Output structure**: Batch of face images

## Evaluation of EdgeFace

![Edge Face](https://gitlab.idiap.ch/bob/bob.paper.tbiom2023_edgeface/-/raw/master/assets/edgeface.png)

| Model                        | MPARAMS | MFLOPs    | LFW (%)      | CA-LFW (%)   | CP-LFW (%)   | CFP-FP (%)   | AgeDB-30 (%) | IJB-B (%) | IJB-C (%) |
|------------------------------|---------|-----------|--------------|--------------|--------------|--------------|--------------|-----------|-----------|
| VarGFaceNet                  | 5.0     | 1022      | 99.85        | 95.15        | 88.55        | 98.50        | 98.15        | 92.9      | 94.7      |
| ShuffleFaceNet 2×            | 4.5     | 1050      | 99.62        | -            | -            | 97.56        | 97.28        | -         | -         |
| MixFaceNet-M                 | 3.95    | 626.1     | 99.68        | -            | -            | -            | 97.05        | 91.55     | 93.42     |
| ShuffleMixFaceNet-M          | 3.95    | 626.1     | 99.60        | -            | -            | -            | 96.98        | 91.47     | 91.47     |
| MobileFaceNetV1              | 3.4     | 1100      | 99.4         | 94.47        | 87.17        | 95.8         | 96.4         | 92.0      | 93.9      |
| ProxylessFaceNAS             | 3.2     | 900       | 99.2         | 92.55        | 84.17        | 94.7         | 94.4         | 87.1      | 89.7      |
| MixFaceNet-S                 | 3.07    | 451.7     | 99.6         | -            | -            | -            | 96.63        | 90.17     | 92.30     |
| ShuffleMixFaceNet-S          | 3.07    | 451.7     | 99.58        | -            | -            | -            | 97.05        | 90.94     | 93.08     |
| ShuffleFaceNet 1.5x          | 2.6     | 577.5     | 99.7         | 95.05        | 88.50        | 96.9         | 97.3         | 92.3      | 94.3      |
| MobileFaceNet                | 2.0     | 933       | 99.7         | 95.2         | 89.22        | 96.9         | 97.6         | 92.8      | 94.7      |
| PocketNetM-256               | 1.75    | 1099.15   | 99.58        | 95.63        | 90.03        | 95.66        | 97.17        | 90.74     | 92.70     |
| PocketNetM-128               | 1.68    | 1099.02   | 99.65        | 95.67        | 90.00        | 95.07        | 96.78        | 90.63     | 92.63     |
| MixFaceNet-XS                | 1.04    | 161.9     | 99.60        | -            | -            | -            | 95.85        | 88.48     | 90.73     |
| ShuffleMixFaceNet-XS         | 1.04    | 161.9     | 99.53        | -            | -            | -            | 95.62        | 87.86     | 90.43     |
| MobileFaceNets               | 0.99    | 439.8     | 99.55        | -            | -            | -            | 96.07        | -         | -         |
| PocketNetS-256               | 0.99    | 587.24    | 99.66        | 95.50        | 88.93        | 93.34        | 96.35        | 89.31     | 91.33     |
| PocketNetS-128               | 0.92    | 587.11    | 99.58        | 95.48        | 89.63        | 94.21        | 96.10        | 89.44     | 91.62     |
| ShuffleFaceNet 0.5x          | 0.5     | 66.9      | 99.23        | -            | -            | 92.59        | 93.22        | -         | -         |
| EdgeFace-S(γ = 0.5)(ours)    | 3.65    | 306.11    | 99.78        | 95.71        | 92.56        | 95.81        | 96.93        | 93.58     | 95.63     |
| EdgeFace-XS(γ = 0.6)(ours)   | 1.77    | 154       | 99.73        | 95.28        | 91.82        | 94.37        | 96.00        | 92.67     | 94.8      |
| Edgeface_XXS (ours)          | 1.24    | 94.72     | 99.57 ± 0.33 | 94.83 ± 0.98 | 90.27 ± 0.93 | 93.63 ± 0.99 | 94.92 ± 1.15 |-          | -         |
|**Edgeface_Base (ours)**      | 18.23   | 1398.83   | 99.83 ± 0.24 | 96.07 ± 1.03 | 93.75 ± 1.16 | 97.01 ± 0.94 | 97.60 ± 0.70 |-          | -         |


### Performance benchmarks of different variants of **EdgeFace**:

| 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   |


## Running EdgeFace-Base

* Minimal code to instantiate the model and perform inference:
``` bash
    import torch
    from torchvision import transforms
    from face_alignment import align
    from backbones import get_model

    # load model
    model_name="edgeface_base"
    model=get_model(model_name)
    checkpoint_path=f'checkpoints/{model_name}.pt'
    # 1. Load the weights into the model
    model.load_state_dict(torch.load(checkpoint_path, map_location='cpu'))

    # 2. Set the model to evaluation mode on its own line
    model.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) 
    transformed_input = transform(aligned) 

    # FIX: Add the batch dimension (turns [3, 112, 112] into [1, 3, 112, 112])
    transformed_input = transformed_input.unsqueeze(0)

    # Move to the same device as the model (crucial if you switched to 'mps' or 'cuda')
    device = next(model.parameters()).device
    transformed_input = transformed_input.to(device)

    # extract embedding
    with torch.no_grad(): # Use no_grad to save memory during inference
    embedding = model(transformed_input)

    print(embedding.shape)

```


Please check the project [GitHub repository](https://gitlab.idiap.ch/bob/bob.paper.tbiom2023_edgeface/)

## License

EdgeFace is released under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)

## Copyright 

(c) 2024, Anjith George, Christophe Ecabert, Hatef Otroshi Shahreza,  Ketan Kotwal, Sébastien Marcel Idiap Research Institute, Martigny 1920, Switzerland.

https://gitlab.idiap.ch/bob/bob.paper.tbiom2023_edgeface/-/blob/master/LICENSE

Please refer to the link for information about the License & Copyright terms and conditions.

## Citation

If you find our work useful, please cite the following publication:

```
@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}
}

```