A PyTorch Toolbox for Face Recognition

Overview

FaceX-Zoo

FaceX-Zoo is a PyTorch toolbox for face recognition. It provides a training module with various supervisory heads and backbones towards state-of-the-art face recognition, as well as a standardized evaluation module which enables to evaluate the models in most of the popular benchmarks just by editing a simple configuration. Also, a simple yet fully functional face SDK is provided for the validation and primary application of the trained models. Rather than including as many as possible of the prior techniques, we enable FaceX-Zoo to easilyupgrade and extend along with the development of face related domains. Please refer to the technical report for more detailed information about this project.

About the name:

  • "Face" - this repo is mainly for face recognition.
  • "X" - we also aim to provide something beyond face recognition, e.g. face parsing, face lightning.
  • "Zoo" - there include a lot of algorithms and models in this repo. image

What's New

  • [Feb. 2021] Mixed precision training by apex is supported. Please check train_amp.py
  • [Jan. 2021] We commit the initial version of FaceX-Zoo.

Requirements

  • python >= 3.7.1
  • pytorch >= 1.1.0
  • torchvision >= 0.3.0

Model Training

See README.md in training_mode, currently support conventional training and semi-siamese training.

Model Evaluation

See README.md in test_protocol, currently support LFW, CPLFW, CALFW, RFW, AgeDB30, MegaFace and MegaFace-mask.

Face SDK

See README.md in face_sdk, currently support face detection, face alignment and face recognition.

Face Mask Adding

See README.md in FMA-3D.

License

FaceX-Zoo is released under the Apache License, Version 2.0.

Acknowledgements

This repo is mainly inspired by InsightFace, InsightFace_Pytorch, face.evoLVe. We thank the authors a lot for their valuable efforts.

Citation

Please consider citing our paper in your publications if the project helps your research. BibTeX reference is as follows.

@article{wang2021facex-zoo,
  title={FaceX-Zoo: A PyTorch Toolbox for Face Recognition},
  author={Wang, Jun and Liu, Yinglu and Hu, Yibo and Shi, Hailin and Mei, Tao},
  journal={arXix preprint arXiv:2101.04407},
  year={2021}
}

If you have any questions, please contact with Jun Wang ([email protected]), Yinglu Liu ([email protected]), Yibo Hu ([email protected]) or Hailin Shi ([email protected]).

Comments
  • Face recognition score

    Face recognition score

    @wang21jun Hello, I have a small question, In this project you used cosine similarity for caculate score between 2 feature. This score can be negative so I wanna normalize it between 0 and 1. Can you share the solution to do it ? Thanks

    opened by buiduchanh 8
  • Wear mask to face but it changes my image quality

    Wear mask to face but it changes my image quality

    Hello,

    Let's explain the issue with below samples: 42 42_masked

    I use add_mask_one script, is_aug is False but sometimes, it somehow changes the whole image content. I just want to wear a mask without effect to my image quality.

    opened by cannguyen275 6
  • Face recognition model in face_sdk

    Face recognition model in face_sdk

    Hi. @wang21jun . Thank for your contribute. I have a question about the model using for recognition, I saw many pretrain model in https://github.com/JDAI-CV/FaceX-Zoo/tree/main/training_mode but I dont know what model you used ? . In config file I saw this model name is face_recognition_1.0 but I dont know the architecture of this model ( backbone, head v..v). Can you share me the details of this model ? Thanks.

    opened by buiduchanh 4
  • About making a mask UV texture map templates

    About making a mask UV texture map templates

    This is a great repo, thanks for sharing.

    I have some problems here. I want to make some new mask UV texture map templates for myself. Could you please provide the uv_mask.png and process scripts? thank you.

    opened by fuxuliu 4
  • 自己训练的模型转onnx失败

    自己训练的模型转onnx失败

    识别模型:ReXNetV1 转换脚本: model_path="out_dir/Epoch_249.pt" onnx_path="models/ReXNetV1.onnx"

    class OnnxConvertor: def init(self): pass def convert(self, model, output_path): img = np.random.randint(0, 255, size=(112,112,3), dtype=np.uint8) img = img[:,:,::-1].astype(np.float32) img = (img.transpose((2, 0, 1)) - 127.5) * 0.0078125 img = torch.from_numpy(img).unsqueeze(0).float() torch.onnx.export( model, img, output_path, keep_initializers_as_inputs=False, verbose=False, opset_version=12 ) # batch inference. onnx_model = onnx.load(output_path) graph = onnx_model.graph graph.input[0].type.tensor_type.shape.dim[0].dim_param = 'None' onnx.save(onnx_model, output_path)

    if name == 'main': model = ReXNetV1(input_ch=16, final_ch=180, width_mult=1.0, depth_mult=1.0, use_se=0, se_ratio=12, out_h=7, out_w=7, feat_dim=512, dropout_ratio=0.2) #model.load_state_dict(torch.load(model_path)["state_dict"]) model_dict = model.state_dict() pretrained_dict = torch.load(model_path)['state_dict'] new_pretrained_dict = {} for k in model_dict: if k.startswith("features."): print(k) new_pretrained_dict[k] = pretrained_dict[k] model_dict.update(new_pretrained_dict) model.load_state_dict(model_dict) model.eval() #dummy_input = torch.randn(1, 3, 112, 112) #torch.onnx.export(model, dummy_input, onnx_path, opset_version=11) convertor = OnnxConvertor() convertor.convert(model, onnx_path)

    opened by 205418367 3
  • 请教加载Resnet50-ir报错“invalid load key, '\xff'.”问题

    请教加载Resnet50-ir报错“invalid load key, '\xff'.”问题

    使用3.1 Experiments of SOTA backbones下的模型时,发现有些模型可以加载成功有些会报错 我的pytorch为1.1.0 GPU版本

    按照如下方式加载MobileFaceNet模型成功 model = MobileFaceNet(512, 7, 7)
    model = nn.DataParallel(model) model.load_state_dict(torch.load(‘model.pt', False)

    但是按照同样方式加载Resnet50-ir模型报错“invalid load key, '\xff'.” model = Resnet(152, 0.4) model = nn.DataParallel(model) model.load_state_dict(torch.load(‘model.pt’, False)

    请问一下要怎么样才能正确加载Resnet50-ir模型?

    opened by GitHubLuGeng 3
  • Attention-92(MX) model at LFW evaluated only 85.9%

    Attention-92(MX) model at LFW evaluated only 85.9%

    i downloaded the pretrained model Attention-92(MX) and the LFW acc announced as 99.82% but as i used the test_lfw.py to get the result , only 85.9% accuracy achieved.

    the log is below:

    backbone param:
    {'stage1_modules': 1, 'stage2_modules': 2, 'stage3_modules': 3, 'feat_dim': 512, 'out_h': 7, 'out_w': 7}
    100%|██████████| 828/828 [06:51<00:00,  2.26it/s]
    6000it [00:00, 22128.20it/s]
    +-------------+---------------+----------------------+
    |  model_name | mean accuracy |    standard error    |
    +-------------+---------------+----------------------+
    | Epoch_17.pt |     0.859     | 0.007375300789011594 |
    +-------------+---------------+----------------------+
    
    Process finished with exit code 0
    

    any idea about it ?

    opened by leoluopy 3
  • Semi-Siamese Training: How to choose appropriate queue_size

    Semi-Siamese Training: How to choose appropriate queue_size

    Hi I tried with "Semi-Siamese Training" and found a config named queue_size in the training_mode/head_config.yaml.

    SST_Prototype: queue_size: 16384 #is divisible by batch size.

    When I read in the paper "Semi-Siamese Training for Shallow Face Learning", author mentioned that

    The size of the gallery queue depends on the number of classes in training datasets, so we empirically set it as 16,384 for shallow and deep data, and 2,560 for QMULSurvFace.

    May I ask how to choose appropriate queue_size with given a custom dataset

    Thank you.

    opened by vmthanh 2
  • what's the difference between Attention-56 and Attention-92(MX)

    what's the difference between Attention-56 and Attention-92(MX)

    Hi,

    I found the trained models in https://github.com/JDAI-CV/FaceX-Zoo/tree/main/training_mode, where you offer Attention-56 and Attention-92(MX).

    However, when I looked at backbone codes backbone and backboneconf, I only saw a single model and configuration.

    As I am gonna use your models as feature extraction backbones, I am wondering how to initialize those two backbones (Attention-56 and Attention-92(MX)) properly.

    Looking forward to your reply. Thanks!

    opened by wuyuuu 2
  • module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu

    module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu

    I start the project on cpu, but getting an error module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu Please tell me how to fix it? I changed loaders with 'cuda:0' -> 'cpu', also i added map_location parameter, but it still doesn't help

    opened by apophatique 2
  • speed up face mask render using cython

    speed up face mask render using cython

    add render.pyx and setup.py under FaceX-Zoo/addition_module/face_mask_adding/FMA-3D/utils/cython to implement render

    before python add_mask_one.py 11.24s user 2.37s system 117% cpu 11.593 total now python add_mask_one.py 3.25s user 2.34s system 159% cpu 3.506 total

    opened by cbwces 2
  • semi-siamese training error

    semi-siamese training error

    An error happen while I try to train the ResNet model with my custom dataset on GoogleColab /content/FaceX-Zoo/training_mode/semi-siamese_training/train_vg.sh: 3: /content/FaceX-Zoo/training_mode/semi-siamese_training/train_vg.sh: mkdire: not found INFO 2022-10-20 04:51:36 train.py: 189] Start optimization. INFO 2022-10-20 04:51:36 train.py: 190] Namespace(alpha=0.999, backbone_conf_file='/content/FaceX-Zoo/training_mode/backbone_conf.yaml', backbone_type='ResNet', batch_size=8, data_root='/content/VN_celeb', epoches=250, evaluate=False, head_conf_file='/content/FaceX-Zoo/training_mode/head_conf.yaml', head_type='ArcFace', log_dir='log', lr=0.1, milestones=[60, 100, 120], momentum=0.9, out_dir='log/model', pretrain_model='/content/resnet152.pt', print_freq=20, resume=False, save_freq=10, step='60,100,120', tensorboardx_logdir='log/board', test_data_conf_file=None, test_set='LFW', train_file='/content/FaceX-Zoo/training_mode/train_list.txt', writer=<tensorboardX.writer.SummaryWriter object at 0x7fe18ac7ba50>) backbone param: {'depth': 152, 'drop_ratio': 0.4, 'net_mode': 'ir_se', 'feat_dim': 512, 'out_h': 7, 'out_w': 7} head param: {'feat_dim': 512, 'num_class': 72778, 'margin_arc': 0.35, 'margin_am': 0.0, 'scale': 32} Valid ids: 1020. /usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary. cpuset_checked)) Traceback (most recent call last): File "/content/FaceX-Zoo/training_mode/semi-siamese_training/train.py", line 191, in train(args) File "/content/FaceX-Zoo/training_mode/semi-siamese_training/train.py", line 125, in train prototype, optimizer, criterion, epoch, conf, loss_meter) File "/content/FaceX-Zoo/training_mode/semi-siamese_training/train.py", line 77, in train_one_epoch images1_probe, images2_gallery, images2_probe, images1_gallery, id_indexes) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() takes 3 positional arguments but 6 were given

    opened by PatWolf2610 0
  • render_cy error

    render_cy error

    when I add mask in folder used render_cy, sometimes I get error face mask 1_133_add_8 1_150_add_6

    but when I rewrite this cython to a python function like def sim_render_cy(vertices, new_colors, triangles, h, w): vertices_shape0 = vertices.shape[1] vis_colors = np.ones((1, vertices_shape0)) face_mask = render_texture(vertices, vis_colors, triangles, h, w, 1) new_image = render_texture(vertices, new_colors, triangles, h, w, 3) return face_mask, new_image

    This error was resolved but it becomes very slow.

    opened by wangrui5781 0
  • [face_sdk] Error when detect and align face-down

    [face_sdk] Error when detect and align face-down

    Hi, Thanks for sharing,

    With face-down image, When I detect and align face, I have got issues: The landmark of face is wrong. Please help me check it face_down test1_landmark_res0

    opened by chuongnvk54 0
Owner
JDAI-CV
JDAI Computer Vision
JDAI-CV
A lightweight face-recognition toolbox and pipeline based on tensorflow-lite

FaceIDLight ?? Description A lightweight face-recognition toolbox and pipeline based on tensorflow-lite with MTCNN-Face-Detection and ArcFace-Face-Rec

Martin Knoche 16 Dec 7, 2022
DVG-Face: Dual Variational Generation for Heterogeneous Face Recognition, TPAMI 2021

DVG-Face: Dual Variational Generation for HFR This repo is a PyTorch implementation of DVG-Face: Dual Variational Generation for Heterogeneous Face Re

null 52 Dec 30, 2022
Face Library is an open source package for accurate and real-time face detection and recognition

Face Library Face Library is an open source package for accurate and real-time face detection and recognition. The package is built over OpenCV and us

null 52 Nov 9, 2022
A large-scale face dataset for face parsing, recognition, generation and editing.

CelebAMask-HQ [Paper] [Demo] CelebAMask-HQ is a large-scale face image dataset that has 30,000 high-resolution face images selected from the CelebA da

switchnorm 1.7k Dec 26, 2022
Pretrained Pytorch face detection (MTCNN) and recognition (InceptionResnet) models

Face Recognition Using Pytorch Python 3.7 3.6 3.5 Status This is a repository for Inception Resnet (V1) models in pytorch, pretrained on VGGFace2 and

Tim Esler 3.3k Jan 4, 2023
🔥🔥High-Performance Face Recognition Library on PaddlePaddle & PyTorch🔥🔥

face.evoLVe: High-Performance Face Recognition Library based on PaddlePaddle & PyTorch Evolve to be more comprehensive, effective and efficient for fa

Zhao Jian 3.1k Jan 2, 2023
Deep Face Recognition in PyTorch

Face Recognition in PyTorch By Alexey Gruzdev and Vladislav Sovrasov Introduction A repository for different experimental Face Recognition models such

Alexey Gruzdev 141 Sep 11, 2022
🔥🔥High-Performance Face Recognition Library on PaddlePaddle & PyTorch🔥🔥

face.evoLVe: High-Performance Face Recognition Library based on PaddlePaddle & PyTorch Evolve to be more comprehensive, effective and efficient for fa

Zhao Jian 3.1k Jan 4, 2023
Official PyTorch implementation of "Improving Face Recognition with Large AgeGaps by Learning to Distinguish Children" (BMVC 2021)

Inter-Prototype (BMVC 2021): Official Project Webpage This repository provides the official PyTorch implementation of the following paper: Improving F

Jungsoo Lee 16 Jun 30, 2022
Pytorch implementation of "Geometrically Adaptive Dictionary Attack on Face Recognition" (WACV 2022)

Geometrically Adaptive Dictionary Attack on Face Recognition This is the Pytorch code of our paper "Geometrically Adaptive Dictionary Attack on Face R

null 6 Nov 21, 2022
img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation

img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation Figure 1: We estimate the 6DoF rigid transformation of a 3D face (rendered in si

Vítor Albiero 519 Dec 29, 2022
Code for HLA-Face: Joint High-Low Adaptation for Low Light Face Detection (CVPR21)

HLA-Face: Joint High-Low Adaptation for Low Light Face Detection The official PyTorch implementation for HLA-Face: Joint High-Low Adaptation for Low L

Wenjing Wang 77 Dec 8, 2022
[TIP 2021] SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction

SADRNet Paper link: SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction Requirements python

Multimedia Computing Group, Nanjing University 99 Dec 30, 2022
Realtime Face Anti Spoofing with Face Detector based on Deep Learning using Tensorflow/Keras and OpenCV

Realtime Face Anti-Spoofing Detection ?? Realtime Face Anti Spoofing Detection with Face Detector to detect real and fake faces Please star this repo

Prem Kumar 86 Aug 3, 2022
Swapping face using Face Mesh with TensorFlow Lite

Swapping face using Face Mesh with TensorFlow Lite

iwatake 17 Apr 26, 2022
Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.

The Face Synthetics dataset Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels. It was introduced in ou

Microsoft 608 Jan 2, 2023
VGGFace2-HQ - A high resolution face dataset for face editing purpose

The first open source high resolution dataset for face swapping!!! A high resolution version of VGGFace2 for academic face editing purpose

Naiyuan Liu 232 Dec 29, 2022
Python tools for 3D face: 3DMM, Mesh processing(transform, camera, light, render), 3D face representations.

face3d: Python tools for processing 3D face Introduction This project implements some basic functions related to 3D faces. You can use this to process

Yao Feng 2.3k Dec 30, 2022
AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Md. Rakibul Islam 1 Jan 13, 2022