| Author | Jian Zhao |
|---|---|
| Homepage | https://zhaoj9014.github.io |
The code of face.evoLVe is released under the MIT License.
:white_check_mark: CLOSED 02 September 2021: ~~Baidu PaddlePaddle officially merged face.evoLVe to faciliate researches and applications on face-related analytics (Official Announcement).~~
:white_check_mark: CLOSED 03 July 2021: ~~Provides training code for the paddlepaddle framework.~~
:white_check_mark: CLOSED 04 July 2019: ~~We will share several publicly available datasets on face anti-spoofing/liveness detection to facilitate related research and analytics.~~
:white_check_mark: CLOSED 07 June 2019: ~~We are training a better-performing IR-152 model on MS-Celeb-1M_Align_112x112, and will release the model soon.~~
:white_check_mark: CLOSED 23 May 2019: ~~We share three publicly available datasets to facilitate research on heterogeneous face recognition and analytics. Please refer to Sec. Data Zoo for details.~~
:white_check_mark: CLOSED 23 Jan 2019: ~~We share the name lists and pair-wise overlapping lists of several widely-used face recognition datasets to help researchers/engineers quickly remove the overlapping parts between their own private datasets and the public datasets. Please refer to Sec. Data Zoo for details.~~
:white_check_mark: CLOSED 23 Jan 2019: ~~The current distributed training schema with multi-GPUs under PyTorch and other mainstream platforms parallels the backbone across multi-GPUs while relying on a single master to compute the final bottleneck (fully-connected/softmax) layer. This is not an issue for conventional face recognition with moderate number of identities. However, it struggles with large-scale face recognition, which requires recognizing millions of identities in the real world. The master can hardly hold the oversized final layer while the slaves still have redundant computation resource, leading to small-batch training or even failed training. To address this problem, we are developing a highly-elegant, effective and efficient distributed training schema with multi-GPUs under PyTorch, supporting not only the backbone, but also the head with the fully-connected (softmax) layer, to facilitate high-performance large-scale face recognition. We will added this support into our repo.~~
:white_check_mark: CLOSED 22 Jan 2019: ~~We have released two feature extraction APIs for extracting features from pre-trained models, implemented with PyTorch build-in functions and OpenCV, respectively. Please check ./util/extract_feature_v1.py and ./util/extract_feature_v2.py.~~
:white_check_mark: CLOSED 22 Jan 2019: ~~We are fine-tuning our released IR-50 model on our private Asia face data, which will be released soon to facilitate high-performance Asia face recognition.~~
:white_check_mark: CLOSED 21 Jan 2019: ~~We are training a better-performing IR-50 model on MS-Celeb-1M_Align_112x112, and will replace the current model soon.~~
:information_desk_person:

:cake:
pip install torch torchvision)pip install mxnet-cu90)pip install tensorflow-gpu)pip install tensorboardX)pip install opencv-python)pip install bcolz)While not required, for optimal performance it is highly recommended to run the code using a CUDA enabled GPU. We used 4-8 NVIDIA Tesla P40 in parallel.
:orange_book:
git clone https://github.com/ZhaoJ9014/face.evoLVe.PyTorch.git.mkdir data checkpoint log at appropriate directory to store your train/val/test data, checkpoints and training logs../data/db_name/
-> id1/
-> 1.jpg
-> ...
-> id2/
-> 1.jpg
-> ...
-> ...
-> ...
-> ...:triangular_ruler:

./alignimg = Image.open('some_img.jpg') # modify the image path to yours
bounding_boxes, landmarks = detect_faces(img) # detect bboxes and landmarks for all faces in the image
show_results(img, bounding_boxes, landmarks) # visualize the results
* Face alignment API (perform face detection, landmark localization and alignment with affine transformations on a whole database foldersource_rootwith the directory structure as demonstrated in Sec. [Usage](#Usage), and store the aligned results to a new folderdest_rootwith the same directory structure):
python face_align.py -source_root [source_root] -dest_root [dest_root] -crop_size [crop_size]
# python face_align.py -source_root './data/test' -dest_root './data/test_Aligned' -crop_size 112
* For macOS users, there is no need to worry about*.DS_Storefiles which may ruin your data, since they will be automatically removed when you run the scripts.
* Keynotes for customed use: 1) specify the arguments ofsource_root,dest_rootandcrop_sizeto your own values when you runface_align.py; 2) pass your customedmin_face_size,thresholdsandnms_thresholdsvalues to thedetect_facesfunction ofdetector.pyto match your practical requirements; 3) if you find the speed using face alignment API is a bit slow, you can call face resize API to firstly resize the image whose smaller size is larger than a threshold (specify the arguments ofsource_root,dest_rootandmin_sideto your own values) before calling the face alignment API:
python face_resize.py
```
:bar_chart:
./balancemin_num samples in the training set root with the directory structure as demonstrated in Sec. Usage for data balance and effective model training):
```
python remove_lowshot.py -root [root] -min_num [min_num]# python remove_lowshot.py -root './data/train' -min_num 10
* Keynotes for customed use: specify the arguments ofrootandmin_numto your own values when you runremove_lowshot.py```.
* We prefer to include other data processing tricks, e.g., augmentation (flip horizontally, scale hue/satuation/brightness with coefficients uniformly drawn from [0.6,1.4], add PCA noise with a coefficient sampled from a normal distribution N(0,0.1), etc.), weighted random sampling, normalization, etc. to the main training script in Sec. Training and Validation to be self-contained.
:coffee:
./config.py:
```python
import torchconfigurations = { 1: dict( SEED = 1337, # random seed for reproduce results
DATA_ROOT = '/media/pc/6T/jasonjzhao/data/faces_emore', # the parent root where your train/val/test data are stored
MODEL_ROOT = '/media/pc/6T/jasonjzhao/buffer/model', # the root to buffer your checkpoints
LOG_ROOT = '/media/pc/6T/jasonjzhao/buffer/log', # the root to log your train/val status
BACKBONE_RESUME_ROOT = './', # the root to resume training from a saved checkpoint
HEAD_RESUME_ROOT = './', # the root to resume training from a saved checkpoint
BACKBONE_NAME = 'IR_SE_50', # support: ['ResNet_50', 'ResNet_101', 'ResNet_152', 'IR_50', 'IR_101', 'IR_152', 'IR_SE_50', 'IR_SE_101', 'IR_SE_152']
HEAD_NAME = 'ArcFace', # support: ['Softmax', 'ArcFace', 'CosFace', 'SphereFace', 'Am_softmax']
LOSS_NAME = 'Focal', # support: ['Focal', 'Softmax']
INPUT_SIZE = [112, 112], # support: [112, 112] and [224, 224]
RGB_MEAN = [0.5, 0.5, 0.5], # for normalize inputs to [-1, 1]
RGB_STD = [0.5, 0.5, 0.5],
EMBEDDING_SIZE = 512, # feature dimension
BATCH_SIZE = 512,
DROP_LAST = True, # whether drop the last batch to ensure consistent batch_norm statistics
LR = 0.1, # initial LR
NUM_EPOCH = 125, # total epoch number (use the firt 1/25 epochs to warm up)
WEIGHT_DECAY = 5e-4, # do not apply to batch_norm parameters
MOMENTUM = 0.9,
STAGES = [35, 65, 95], # epoch stages to decay learning rate
DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu"),
MULTI_GPU = True, # flag to use multiple GPUs; if you choose to train with single GPU, you should first run "export CUDA_VISILE_DEVICES=device_id" to specify the GPU card you want to use
GPU_ID = [0, 1, 2, 3], # specify your GPU ids
PIN_MEMORY = True,
NUM_WORKERS = 0,
), } ``` * Train \& validation API (all folks about training \& validation, i.e., import
$ claude mcp add face.evoLVe \
-- python -m otcore.mcp_server <graph>