Emphasizing Closeness and Diversity Simultaneously for Deep Face Representation

Installation

1) Main Requirements

  • pytorch == 1.7.1
  • torchvision == 0.8.2
  • CUDA 11
  • Python 3

2) Clone the repository

git clone https://github.com/Zacharynjust/FR-closeness-and-diversity.git --recursive

3) Install the wheels

cd FR-closeness-and-diversity
pip install -r requirements.txt

Evaluation

This repo provides a united evaluation script for several FR benchmarks.

Currently, it supports small benchmark verification (e.g., LFW, CFP-FP, and AgeDB) and IJB verification, the code is mainly borrowed from insightface, MagFace, and AdaFace.

It also supports MegaFace verification and identification, the code is mainly borrowed from FFC. The advantage of this script is that it does not require an OpenCV-2.4 environment and works much faster; however, the identification protocol is a little different from the MegaFace official implementation, which may cause a slight performance drop (about 0.05 in our case).

1) Download our pretrained model

[Baidu Cloud] [Google Drive]

2) Download evaluation datasets

For small benchmark evaluations (e.g., LFW, CFP-FP, and AgeDB), you can download them from [Baidu Cloud] [Google Drive] and then put *.bin in eval_data folder.

For IJB evaluation, you can access the datasets via the official link or insightface. (Please apply for permissions from NIST before your usage.)

For MegaFace evaluation, you can access the datasets and development kit via the official link or [Baidu Cloud]. (Please apply for permissions before your usage.)

3) Customize the config file

Specify the model path and the dataset path in eval_config.py

4) Run evaluation script

python evaluate.py --opt eval

Training

1) Customize the config file

This repo provides a training script to represent our paper, all you need is to specify training settings in config.py. Because a two-stage pipeline is adopted in our paper, we also provide the code to train vanilla ArcFace, see pretrain.py

2) Train with ArcFace

Train plain ArcFace for a few epochs (e.g. 4) to get stable difficulty scores.

Note that you need to manually specify pretrain setting entry in config.py

CUDA_VISIBLE_DEVICES="0,1,2,3" python pretrain.py --opt pretrain

3) Train with Proposed Framework

In this step, you need to firstly specify model & difficulty score paths in order to resume the pretrained model.

CUDA_VISIBLE_DEVICES="0,1,2,3" python train.py

Contact

If you have any questions about this work, please contact the author by email at cyzhao@njust.edu.cn

Cite

If you find this code useful in your research, please consider citing us:

@inproceedings{zhao2022emphasizing,
  title={Emphasizing Closeness and Diversity Simultaneously for Deep Face Representation},
  author={Zhao, Chaoyu and Qian, Jianjun and Zhu, Shumin and Xie, Jin and Yang, Jian},
  booktitle={Proceedings of the Asian Conference on Computer Vision},
  pages={3430--3446},
  year={2022}
}

Acknowledgment

This repo is built upon several excellent repos, e.g., insightface, face.evoLVe, CurricularFace, MagFace, AdaFace, and FFC.