Skip to content

Latest commit

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Installation

Setup with Conda

# create a new environment
conda create --name insightKface python=3.7 # or over
conda activate insightKface
#install the appropriate cuda version of pytorch(https://pytorch.org/)#example:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
# install requirements
pip install -r requirements.txt

Data prepration

K-FACE Database

K-FACE AI-hub.

Detail configuration about K-FACE is provided in the paper below.

K-FACE: A Large-Scale KIST Face Database in Consideration with Unconstrained Environments

K-FACE sample images

title

Structure of the K-FACE database

title

Configuration of K-FACE

Configuration_of_KFACE

Detection & Alignment on K-FACE

""" ################################################################### K-Face : Korean Facial Image AI Dataset url : http://www.aihub.or.kr/aidata/73 Directory structure : High-ID-Accessories-Lux-Emotion ID example : '19062421' ... '19101513' len 400 Accessories example : 'S001', 'S002' .. 'S006' len 6 Lux example : 'L1', 'L2' .. 'L30' len 30 Emotion example : 'E01', 'E02', 'E03' len 3 ###################################################################"""# examplecd detection
python align_kfaces.py --ori_data_path '/data/FACE/KFACE/High' --detected_data_path 'kface_retina_align_112x112'

Training and test datasets on K-FACE

Train IDAccessoriesLuxExpressionPose#ImageVariance
T1A11000E1C4-102,590Very Low
T2A1-2400-1000E1C4-1046,620Low
T3A1-A4200-1000E1-2C4-13654,160Middle
T4A1-A640-1000E1-3C1-203,862,800High
Test IDAccessoriesLuxExpressionPose#PairsVariance
Q1A11000E1C4-101,000Very Low
Q2A1-2400-1000E1C4-10100,000Low
Q3A1-4200-1000E1-2C4-13100,000Middle
Q4A1-640-1000E1-3C1-20100,000High

MS1M-RetinaFace download link:

  1. The Lightweight Face Recognition Challenge & Workshop.

  2. https://github.com/deepinsight/insightface/wiki/Dataset-Zoo

#Preprocess 'train.rec' and 'train.idx' to 'jpg'# examplecd detection
python rec2image.py --include '/data/FACE/ms1m-retinaface-t1/' --output 'MS1M-RetinaFace'

Inference

After downloading the pretrained model, run test.py.

Pretrained Model

For all experiments, ResNet-34 was chosen as the baseline backbone.

The model was trained on KFACE

Head&LossQ1Q2Q3Q4
ArcFace (s=16, m=0.25)98.3094.7787.8785.41
SN-pair (s=64)99.2095.0191.8489.74
MixFace (e=1e-22, m=0.25)10096.3792.3689.80

Note:

  • For ArcFace, We tested (s,m)={(16,0.5), (32,0.25), (64,0.25), (32,0.5), (64,0.5)}, but the model was not trained properly So, we apply (s,m)=(16,0.25).
cd recognition
# example
python test.py --weights 'kface.mixface.1e-22m0.25.best.pt' --dataset 'kface' --data_cfg 'data/KFACE/kface.T4.yaml'

The model was trained on MS1M-R

Head&LossQ2Q3Q4LFWCFP-FPAgeDB-30
ArcFace (s=64, m=0.5)98.7186.6082.0399.8098.4198.80
SN-pair (s=64)92.8576.3670.0899.5596.2095.46
MixFace (e=1e-22, m=0.5)97.3682.8976.9599.6897.7497.25
cd recognition
# example
python test.py --weights 'face.mixface.1e-22m0.5.best.pt' --dataset 'face' --data_cfg 'data/face.all.yaml'

The model was trained on MS1M-R+T4

Head&LossQ2Q3Q4LFWCFP-FPAgeDB-30
ArcFace (s=8, m=0.25)76.5873.1371.3899.4696.7593.83
SN-pair (s=64)98.3794.9893.3399.4594.9093.45
MixFace (e=1e-22, m=0.5)99.2796.8594.7999.5396.3295.56

Note:

  • For ArcFace, we tested (s,m)={(8, 0.5), (16, 0.25), (16,0.5), (32,0.25), (64,0.25), (32,0.5), (64,0.5)}, but the model was not trained properly So, we apply (s,m)=(8,0.25).
cd recognition
# example
python test.py --weights 'merge.mixface.1e-22m0.5.best.pt' --dataset 'merge' --data_cfg 'data/merge.yaml'

Training

Multi-GPU DataParallel Mode

Example script for training on KFACE

cd recognition
# example 
python train.py --dataset 'kface' --head 'mixface' --data_cfg 'data/KFACE/kface.T4.yaml' --hyp 'data/face.hyp.yaml' --head_cfg 'models/head.kface.cfg.yaml' --name 'example' --device 0,1

Multi-GPU DistributedDataParallel Mode

Example script for training on KFACE

cd recognition
# example
python -m torch.distributed.launch --nproc_per_node 2 train.py --dataset 'kface' --head 'mixface' --data_cfg 'data/KFACE/kface.T4.yaml' --hyp 'data/face.hyp.yaml' --head_cfg 'models/head.kface.cfg.yaml' --name 'example' --device 0,1

Note:

  • For MS1M-R, change args --dataset face, --data_cfg data/face.all.yaml, and --head_cfg model/head.face.cfg.yaml.
  • For MS1M-R+T4, change args --dataset merge, --data_cfg data/merge.yaml, and --head_cfg model/head.merge.cfg.yaml.
  • The args --nodrop should be used if you train with the metric loss(e.g., SN-pair, N-pair, etc.) on MS1M-R or MS1M-R+T4.
  • The args --double should be used if you train with the metric loss(e.g., SN-pair, N-pair, etc.) or MixFace on MS1M-R or MS1M-R+T4.
  • DistributedDataParallel is only available to classification loss(e.g., arcface, cosface, etc.)

Reference code

Thanks for these source codes porviding me with knowledges to complete this repository.

  1. https://github.com/biubug6/Pytorch_Retinaface.
  2. https://github.com/deepinsight/insightface.
  3. https://github.com/ultralytics/yolov5

About

K-FACE Analysis Project on Pytorch

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages