Reference: https://github.com/deepinsight/insightface (Official repository of ArcFace)
Create your dataset like the sample dataset:
data
--YourDatasetName
--Label 1
----image1.jpg
----image2.jpg
----...
--Label 2
----...
You can find pretrained model at link
For face alignment, run
python align_face.py --root_dir /path/to/dataset/folder --dst_w 112 --dst_h 112(You can change the destination size --dst_w is output width and --dst_h is output height)
loss: Now you can chooseArcFaceorElasticArcFace.backbone: Find supported backbone in ArcFaceModel's docstring.irse50andmobilefacenethave pretrained models on insightface's datasets at link. Other ones are listed in the doctring ofArcFaceModelclass, but they have to be trained from scratch.freeze_model: Freeze the backbone of trained model for transfer learning. Set its value isfalseto train from scratch.root_dir: The path to the directory of train datasetuse_lr_scheduler: Use learning rate scheduler.optimizer: Optimizer for training progress.sam,lamb,adamandadanare supported optimizer. You can find the original implementation of SAM, LAMB and Adan. If you don't change the config, the default optimizer is ADAM.verbose: 0: nothing will be shown; 1: shows results per epoch only; 2: shows train losses per iterationprefix: Prefix of saved model's name.
trainset_path: Path to the directory of dataset used for training the test model.testset_path: Path to the directory of test dataset.pretrained_model_path: Path to the pretrained model.
In terminal, run
python main.py --config ./path/to/config/file.json --phase train --device [gpu_id]Currently, only training on a single gpu is supported.
In terminal, run
python main.py --config ./path/to/config/file.json --phase test --device [gpu_id]In terminal, run
python verification.py --config ./path/to/config/file.jsonInference on single image is also supported, check the commented lines in the verification.py file. Filling hair is a miscellaneous option to observe the decrease of model's performance when the given face is partly covered.