A trusty face recognition research platform developed by Tencent Youtu Lab

Related tags

Deep Learning TFace
Overview

Introduction

TFace: A trusty face recognition research platform developed by Tencent Youtu Lab. It provides a high-performance distributed training framework and releases our efficient methods implementation.

This framework consists of several modules: 1. various data augmentation methods, 2. backbone model zoo, 3. our proposed methods for face recognition and face quality, 4. test protocols of evalution results and model latency.

Recent News

2021.3: SDD-FIQA: Unsupervised Face Image Quality Assessment with Similarity Distribution Distance accepted by CVPR2021. [paper] [code]

2021.3: Consistent Instance False Positive Improves Fairness in Face Recognition accepted by CVPR2021. [paper] [code]

2021.3: Spherical Confidence Learning for Face Recognition accepted by CVPR2021. [paper] [code]

2020.8: Improving Face Recognition from Hard Samples via Distribution Distillation Loss accepted by ECCV2020. [paper] [code]

2020.3: Curricularface: adaptive curriculum learning loss for deep face recognition has been accepted by CVPR2020. [paper] [code]

Requirements

  • python==3.6.0
  • torch==1.6.0
  • torchvision==0.7.0
  • tensorboard==2.4.0
  • Pillow==5.0.0

Getting Started

Train Data

The training dataset is organized in tfrecord format for efficiency. The raw data of all face images are saved in tfrecord files, and each dataset has a corresponding index file(each line includes tfrecord_name, trecord_index offset, label).

The IndexTFRDataset class will parse the index file to gather image data and label for training. This form of dataset is convenient for reorganization in data cleaning(do not reproduce tfrecord, just reproduce the index file).

  1. Convert raw image to tfrecords, generate a new data dir including some tfrecord files and a index_map file
python3 tools/img2tfrecord.py --img_list=${img_list} --pts_list=${pts_list} --tfrecords_name=${tfr_data_name}
  1. Convert old index file(each line includes image path, label) to new index file
python3 tools/convert_new_index.py --old=${old_index} --tfr_index=${tfr_index} --new=${new_index}
  1. Decode the tfrecords to raw image
python3 tools/decode.py --tfrecords_dir=${tfr_dir} --output_dir=${output_dir}

Augmentation

Data Augmentation module implements some 2D-based methods to generated some hard samples, e.g., maks, glass, headscarf. Details see Augmentation

Train

Modified the DATA_ROOTandINDEX_ROOTin ./tasks/distfc/train_confing.yaml, DATA_ROOT is the parent dir for tfrecord dir, INDEX_ROOT is the parent dir for index file.

bash local_train.sh

Test

Detail codes and steps see Test

Benchmark

Evaluation Results

Backbone Head Data LFW CFP-FP CPLFW AGEDB CALFW IJBB (TPR@FAR=1e-4) IJBC (TPR@FAR=1e-4)
IR_101 ArcFace MS1Mv2 99.77 98.27 92.08 98.15 95.45 94.2 95.6
IR_101 CurricularFace MS1Mv2 99.80 98.36 93.13 98.37 96.05 94.86 96.15
IR_18 ArcFace MS1Mv2 99.65 94.89 89.80 97.23 95.60 90.06 92.39
IR_34 ArcFace MS1Mv2 99.80 97.27 91.75 98.07 95.97 92.88 94.65
IR_50 ArcFace MS1Mv2 99.80 97.63 92.50 97.92 96.05 93.45 95.16
MobileFaceNet ArcFace MS1Mv2 99.52 91.66 87.93 95.82 95.12 87.07 89.13
GhostNet_x1.3 ArcFace MS1Mv2 99.65 94.20 89.87 96.95 95.58 89.61 91.96
EfficientNetB0 ArcFace MS1Mv2 99.60 95.90 91.07 97.58 95.82 91.79 93.67
EfficientNetB1 ArcFace MS1Mv2 99.60 96.39 91.75 97.65 95.73 92.43 94.43

Backbone model size & latency

The device and platform information see below:

Device Inference Framework
x86 cpu Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz Openvino
arm Kirin 980 TNN

Test results for different backbones and different devices:

Backbone Model Size(fp32) X86 CPU ARM
EfficientNetB0 16MB 26.29ms 32.09ms
EfficientNetB1 26MB 35.73ms 46.5ms
MobileFaceNet 4.7MB 7.63ms 15.61ms
GhostNet_x1.3 16MB 25.70ms 27.58ms
IR_18 92MB 57.34ms 94.58ms
IR_34 131MB 105.58ms NA
IR_50 167MB 165.95ms NA
IR_101 249MB 215.47ms NA

Acknowledgement

This repo is modified and adapted on these great repositories, we thank theses authors a lot for their greate efforts.

Comments
  • Threshold parameter ru+ in CIFP work

    Threshold parameter ru+ in CIFP work

    Thanks for the CIFP work on CVPR2021, it's very impressive! I'd like to check about the hyper-parameter setting. As mentioned in the paper, ru+ is set to be 1e-4 according to the experiment. However, in the code of cifp.py, I didn't find any definition of it. Could you please offer some instruction on this?

    opened by milliema 9
  • SDD-FIQA results understanding

    SDD-FIQA results understanding

    Hi, first of all, thanks for your work.

    I decided to test it with pre-trained model and some own real images. I run eval.py demo to check it out. But I am confused with the results of quality scores.

    1. What ranges of quality score values can be considered as low, medium, high for SDD_FIQA_checkpoints_r50.pth model?

    Referring to the paper, Fig3, I can guess the following value [low: 0 - 35, medium: 36 - 48, high: 49 - 100]. So I wonder to hear your suggestion about it.

    1. Do these ranges depend on the model? It seems that yes, but correct me if I am wrong.

    2. Did you performed experiments with face occlusion, how its robust on it?

    IMHO, there is no rough thresholds which separate low vs medium vs high sub-ranges, there are some overlaps between them. And these overlaps make me feeling that there is not clear enough quality scores dependency between low, medium and high quality face images.

    Thanks~

    opened by lstomy 6
  • Pre-trained model loading error

    Pre-trained model loading error

    Thank you very much for this work!

    Inconsistent quantities caused the loading to fail. Do you know why? Thanks~

    • tasks/distfc/README.md IR101 pretrained model: OrderedDict len is 672
    • torchkit/backbone/model_irse.py IR101:OrderedDict len is 917
    opened by bobo0810 2
  • Create Face Anti Spoofing dataset

    Create Face Anti Spoofing dataset

    Im very interested in your project. So can you share with me a sample or structure about the dataset. I don't know how to created it. Thank you so much!

    opened by thangdt277 1
  • Assertion Error

    Assertion Error

    image

    sh ./train.sh -1 "/home/adesoji/tfaceenv/TFace-master/security/tasks/Face-Anti-Spoofing/DCN/configs" 5000

    Running this command below resulted intoAssertion Error, how do i correct this? /home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launch.py:178: FutureWarning: The module torch.distributed.launch is deprecated and will be removed in future. Use torchrun. Note that --use_env is set by default in torchrun. If your script expects --local_rank argument to be set, please change it to read from os.environ['LOCAL_RANK'] instead. See https://pytorch.org/docs/stable/distributed.html#launch-utility for further instructions

    warnings.warn( Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launch.py", line 193, in main() File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launch.py", line 189, in main launch(args) File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launch.py", line 174, in launch run(args) File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/run.py", line 752, in run elastic_launch( File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 131, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 214, in launch_agent spec = WorkerSpec( File "", line 15, in init File "/home/adesoji/tfaceenv/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 87, in post_init assert self.local_world_size > 0 AssertionError

    opened by Adesoji1 1
  • FileNotFoundError: [Errno 2] No such file or directory

    FileNotFoundError: [Errno 2] No such file or directory

    Running the train.py script ion ubuntu 20.04, python 3.8, i have this error written below

    FileNotFoundError: [Errno 2] No such file or directory: '/home/adesoji/TFace-master/TFace-master/security/tasks/Face-Anti-Spoofing/ANRL/configs/train.yaml'

    Kindly provide this config file

    opened by Adesoji1 1
  • Face-antispoof pretrained model

    Face-antispoof pretrained model

    Recently, I am reproducing your paper--ANRL. I have four datasets(I&C&M&O), and train a model based on your source code. In I&C&m to O task, the EER of O is above 0.3, while in the training dataset, the EER is very low, below 0.001. I don't know why. Can you provide me a pretrained model.

    opened by tyyff 1
  • Multi-gpu training got an unbanlanced memory and redundant processes

    Multi-gpu training got an unbanlanced memory and redundant processes

    I train models in multi-GPUs(4 gpus here) behavior. But once I tried to load pretrained model, the nvidia-smi shown that another 4 redundant processes(8 processes in total) occupied the GPU 0, while not loading pretrained model those processes disappeared(4 process in total). Those redundant processes increase along with the GPU numbers you use, and due to small number of batch size in sum. And could you let me known how to keep redundant processes from appearing when train using multi-GPUs and loading pretrained model?

    opened by gaojingqian 1
  • How to run example?

    How to run example?

    Thank you for perfect repository <3

    • I see that you implemented many papers in task directory. I see training code but I cannot see any example code to run that model
    • Can you show me how to run with pre-trained model in TFace/tasks/cifp/ ? (Extract feature + verify)
    • Thank you so much
    opened by huytuong010101 1
  • ImportError: attempted relative import with no known parent package

    ImportError: attempted relative import with no known parent package

    When I run local_train.sh, it returns the error below:

    Traceback (most recent call last):
      File "./tasks/cifp/train_cifp.py", line 9, in <module>
        from ..localfc.train_localfc import TrainTask
    ImportError: attempted relative import with no known parent package
    Traceback (most recent call last):
      File "./tasks/cifp/train_cifp.py", line 9, in <module>
        from ..localfc.train_localfc import TrainTask
    ImportError: attempted relative import with no known parent package
    Traceback (most recent call last):
      File "./tasks/cifp/train_cifp.py", line 9, in <module>
        from ..localfc.train_localfc import TrainTask
    ImportError: attempted relative import with no known parent package
    Traceback (most recent call last):
      File "/root/miniconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/root/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/launch.py", line 260, in <module>
        main()
      File "/root/miniconda3/lib/python3.8/site-packages/torch/distributed/launch.py", line 255, in main
        raise subprocess.CalledProcessError(returncode=process.returncode,
    subprocess.CalledProcessError: Command '['/root/miniconda3/bin/python', '-u', './tasks/cifp/train_cifp.py', '--local_rank=7']' returned non-zero exit status 1.
    

    The content of my local_train.sh is:

    #!/bin/bash
    
    if [ ! -d "logs" ]; then
        mkdir logs
    fi
    export CUDA_VISIBLE_DEVICES='2'
    nohup python -u -m torch.distributed.launch --nproc_per_node=8 --nnodes=1 ./tasks/cifp/train_cifp.py > logs/$(date +%F-%H-%M-%S).log 2>&1 &
    
    opened by zhoufengfan 1
  • 关于Dual Contrastive Learning for General Face Forgery Detection复现

    关于Dual Contrastive Learning for General Face Forgery Detection复现

    复现时出现如下问题,可否提供一下celedf的目录结构呢? 按原始版本celedf-v2的目录结构会出现确认错误的问题 image

    自己按每个文件名建立文件夹再放进去后不会再报这个确认的错,但是会在下面标签的地方报错 image

    应该是目录结构和作者不匹配,望有大佬能告知如何处置

    另外请问下这个代码好像不用自己抽帧吧?

    opened by joylne 1
  • 论文结果无法复现

    论文结果无法复现

    您好,因为git中未公开教师模型IR50的权重,所以我在其他的git上面找了一个测试结果差不多的权重,在基于mobilefacenet复现结果时,发现结果无法对齐,在CFP和CPLFW两个测试集上差距较大,CFP复现结果为91.97%,CPLFW复现结果为86.6%,都与论文给出的结果相差2%以上?请问是什么原因呢? 另外,我发现论文中的一些超参数和代码中默认的超参数并未完全一致,如: epoch数(论文中为28,代码中为26) learning rate schedule(论文中为10,18,24;代码中为10,18,22) margin m(论文中为0.5;代码中为0.4)

    我分别使用了论文中的超参数和代码中的超参数训练后,发现结果还是无法对齐,请问可能是什么原因呢

    opened by cobraheleah 2
  • dctdp

    dctdp

    很感谢你们的开源代码,但是我在复现dctdp这篇文章的时候发现,代码里面对于图像加的噪声十分小,然后,我对他进行了逆DCT变换,结果发现加入的噪声对于最终图像基本没有影响,另外,由于设备的原因,我无法完全重现论文中的实验过程,但是,我用相同的方法在另一个小型的数据集上进行了实验,发现,如果去除了图像的DC通道,将会对实验结果有着非常严重的影响,我想知道,噪声加入的那么小是否合适?另外,去除DC通道是只有在人脸图像上才有效果吗?

    opened by zz978233034 2
  • EKD train.py

    EKD train.py

    您好,想请问一下

    1. train.py是用TFace/recognition下面的,还是TFace/recognition/tasks/ekd,因为我看好像TFace/recognition/tasks/ekd/train.py并不支持一些功能,比如混合精度
    2. dataloader的sampler采用了BalancedBatchSampler,并不是DistributedSampler,而且里面也没有类似分布式的操作,这样意味着每个worker读的数据都是一样的吗
    opened by cobraheleah 1
Owner
Tencent
Tencent
RITA is a family of autoregressive protein models, developed by LightOn in collaboration with the OATML group at Oxford and the Debora Marks Lab at Harvard.

RITA: a Study on Scaling Up Generative Protein Sequence Models RITA is a family of autoregressive protein models, developed by a collaboration of Ligh

LightOn 69 Dec 22, 2022
FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.

Detectron is deprecated. Please see detectron2, a ground-up rewrite of Detectron in PyTorch. Detectron Detectron is Facebook AI Research's software sy

Facebook Research 25.5k Jan 7, 2023
piSTAR Lab is a modular platform built to make AI experimentation accessible and fun. (pistar.ai)

piSTAR Lab WARNING: This is an early release. Overview piSTAR Lab is a modular deep reinforcement learning platform built to make AI experimentation a

piSTAR Lab 0 Aug 1, 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
A modular framework for vision & language multimodal research from Facebook AI Research (FAIR)

MMF is a modular framework for vision and language multimodal research from Facebook AI Research. MMF contains reference implementations of state-of-t

Facebook Research 5.1k Jan 4, 2023
A platform for intelligent agent learning based on a 3D open-world FPS game developed by Inspir.AI.

Wilderness Scavenger: 3D Open-World FPS Game AI Challenge This is a platform for intelligent agent learning based on a 3D open-world FPS game develope

null 46 Nov 24, 2022
Implementation of QuickDraw - an online game developed by Google, combined with AirGesture - a simple gesture recognition application

QuickDraw - AirGesture Introduction Here is my python source code for QuickDraw - an online game developed by google, combined with AirGesture - a sim

Viet Nguyen 89 Dec 18, 2022
A Research-oriented Federated Learning Library and Benchmark Platform for Graph Neural Networks. Accepted to ICLR'2021 - DPML and MLSys'21 - GNNSys workshops.

FedGraphNN: A Federated Learning System and Benchmark for Graph Neural Networks A Research-oriented Federated Learning Library and Benchmark Platform

FedML-AI 175 Dec 1, 2022
Megaverse is a new 3D simulation platform for reinforcement learning and embodied AI research

Megaverse Megaverse is a new 3D simulation platform for reinforcement learning and embodied AI research. The efficient design of the engine enables ph

Aleksei Petrenko 191 Dec 23, 2022
FastReID is a research platform that implements state-of-the-art re-identification algorithms.

FastReID is a research platform that implements state-of-the-art re-identification algorithms.

JDAI-CV 2.8k Jan 7, 2023
Clinica is a software platform for clinical research studies involving patients with neurological and psychiatric diseases and the acquisition of multimodal data

Clinica Software platform for clinical neuroimaging studies Homepage | Documentation | Paper | Forum | See also: AD-ML, AD-DL ClinicaDL About The Proj

ARAMIS Lab 165 Dec 29, 2022
A PyTorch library and evaluation platform for end-to-end compression research

CompressAI CompressAI (compress-ay) is a PyTorch library and evaluation platform for end-to-end compression research. CompressAI currently provides: c

InterDigital 680 Jan 6, 2023
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