«facenet» re-implements the paper FaceNet: A Unified Embedding for Face Recognition and Clustering
Based on the similarity implementation, the following functions have been added:
- Add configuration file module to support configurable training parameters;
- Support Multi-GPU training and Mixed-Precision training;
- Add a variety of preprocessing functions and training configuration.
About training results for FMNIST/CIFAR/LFW
, see details
facenet is an excellent face recognition paper, which innovatively puts forward a new training paradigm - triplet loss training
. The core idea of triple loss is to reduce the Euclidean distance between similar faces and expand the distance between different classes as much as possible. Every training needs to collect training images (anchor points), positive samples of the same class and negative samples of different classes.
similarity provides an excellent facenet
' training project. Before each round of training, distribute the data through the sampler to ensure that each batch of data contains p
categories and each category has k
training samples; After the forward calculation is completed, pairwise calculation is carried out on the same batch of data, and the positive and negative sample pairs that meet the definition of semi-hard
(the negative sample is not closer to the anchor point than the positive sample, but its distance is still within the boundary range) are collected to participate in the loss function calculation.
The deficiency of the above project lies in that it does not support multi-GPU training, mixed precision training and no good modular design, which leads to weak scalability and can not be directly applied to practical applications. In order to better train facenet
, this warehouse has enhanced the operation based on similarity, providing a more friendly training implementation.
$ pip install -r requirements.txt
- Get data file. See how to get data
- Training
- Single GPU training
$ CUDA_VISIBLE_DEVICES=0 python tools/train.py -cfg=configs/lfw/r18_lfw_224_e2_adam_g1.yaml
- Multi GPU training
$ CUDA_VISIBLE_DEVICES=0,1,2,3 python tools/train.py -cfg=configs/lfw/r18_lfw_224_e2_adam_g4.yaml
- Single GPU training
- zhujian - Initial work - zjykzj
@article{2015,
title={FaceNet: A unified embedding for face recognition and clustering},
url={http://dx.doi.org/10.1109/CVPR.2015.7298682},
DOI={10.1109/cvpr.2015.7298682},
journal={2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
publisher={IEEE},
author={Schroff, Florian and Kalenichenko, Dmitry and Philbin, James},
year={2015},
month={Jun}
}
Anyone's participation is welcome! Open an issue or submit PRs.
Small note:
- Git submission specifications should be complied with Conventional Commits
- If versioned, please conform to the Semantic Versioning 2.0.0 specification
- If editing the README, please conform to the standard-readme specification.
Apache License 2.0 © 2021 zjykzj