InsightFace: 2D and 3D Face Analysis Project on MXNet and PyTorch

Overview

InsightFace: 2D and 3D Face Analysis Project

By Jia Guo and Jiankang Deng

Top News

2021-06-05: We launch a Masked Face Recognition Challenge & Workshop on ICCV 2021.

2021-05-15: We released an efficient high accuracy face detection approach called SCRFD.

2021-04-18: We achieved Rank-4th on NIST-FRVT 1:1, see leaderboard.

2021-03-13: We have released our official ArcFace PyTorch implementation, see here.

License

The code of InsightFace is released under the MIT License. There is no limitation for both academic and commercial usage.

The training data containing the annotation (and the models trained with these data) are available for non-commercial research purposes only.

Introduction

InsightFace is an open source 2D&3D deep face analysis toolbox, mainly based on MXNet and PyTorch.

The master branch works with MXNet 1.2 to 1.6, PyTorch 1.6+, with Python 3.x.

ArcFace Video Demo

ArcFace Demo

Please click the image to watch the Youtube video. For Bilibili users, click here.

Recent Update

2021-06-05: We launch a Masked Face Recognition Challenge & Workshop on ICCV 2021.

2021-05-15: We released an efficient high accuracy face detection approach called SCRFD.

2021-04-18: We achieved Rank-4th on NIST-FRVT 1:1, see leaderboard.

2021-03-13: We have released our official ArcFace PyTorch implementation, see here.

2021-03-09: Tips for training large-scale face recognition model, such as millions of IDs(classes).

2021-02-21: We provide a simple face mask renderer here which can be used as a data augmentation tool while training face recognition models.

2021-01-20: OneFlow based implementation of ArcFace and Partial-FC, here.

2020-10-13: A new training method and one large training set(360K IDs) were released here by DeepGlint.

2020-10-09: We opened a large scale recognition test benchmark IFRT

2020-08-01: We released lightweight facial landmark models with fast coordinate regression(106 points). See detail here.

2020-04-27: InsightFace pretrained models and MS1M-Arcface are now specified as the only external training dataset, for iQIYI iCartoonFace challenge, see detail here.

2020.02.21: Instant discussion group created on QQ with group-id: 711302608. For English developers, see install tutorial here.

2020.02.16: RetinaFace now can detect faces with mask, for anti-CoVID19, see detail here

2019.08.10: We achieved 2nd place at WIDER Face Detection Challenge 2019.

2019.05.30: Presentation at cvmart

2019.04.30: Our Face detector (RetinaFace) obtains state-of-the-art results on the WiderFace dataset.

2019.04.14: We will launch a Light-weight Face Recognition challenge/workshop on ICCV 2019.

2019.04.04: Arcface achieved state-of-the-art performance (7/109) on the NIST Face Recognition Vendor Test (FRVT) (1:1 verification) report (name: Imperial-000 and Imperial-001). Our solution is based on [MS1MV2+DeepGlintAsian, ResNet100, ArcFace loss].

2019.02.08: Please check https://github.com/deepinsight/insightface/tree/master/recognition/ArcFace for our parallel training code which can easily and efficiently support one million identities on a single machine (8* 1080ti).

2018.12.13: Inference acceleration TVM-Benchmark.

2018.10.28: Light-weight attribute model Gender-Age. About 1MB, 10ms on single CPU core. Gender accuracy 96% on validation set and 4.1 age MAE.

2018.10.16: We achieved state-of-the-art performance on Trillionpairs (name: nttstar) and IQIYI_VID (name: WitcheR).

Contents

Deep Face Recognition

Face Detection

Face Alignment

Citation

Contact

Deep Face Recognition

Introduction

In this module, we provide training data, network settings and loss designs for deep face recognition. The training data includes, but not limited to the cleaned MS1M, VGG2 and CASIA-Webface datasets, which were already packed in MXNet binary format. The network backbones include ResNet, MobilefaceNet, MobileNet, InceptionResNet_v2, DenseNet, etc.. The loss functions include Softmax, SphereFace, CosineFace, ArcFace, Sub-Center ArcFace and Triplet (Euclidean/Angular) Loss.

You can check the detail page of our work ArcFace(which accepted in CVPR-2019) and SubCenter-ArcFace(which accepted in ECCV-2020).

margin penalty for target logit

Our method, ArcFace, was initially described in an arXiv technical report. By using this module, you can simply achieve LFW 99.83%+ and Megaface 98%+ by a single model. This module can help researcher/engineer to develop deep face recognition algorithms quickly by only two steps: download the binary dataset and run the training script.

Training Data

All face images are aligned by ficial five landmarks and cropped to 112x112:

Please check Dataset-Zoo for detail information and dataset downloading.

  • Please check recognition/tools/face2rec2.py on how to build a binary face dataset. You can either choose MTCNN or RetinaFace to align the faces.

Train

  1. Install MXNet with GPU support (Python 3.X).
pip install mxnet-cu101 # which should match your installed cuda version
  1. Clone the InsightFace repository. We call the directory insightface as INSIGHTFACE_ROOT.
git clone --recursive https://github.com/deepinsight/insightface.git
  1. Download the training set (MS1M-Arcface) and place it in $INSIGHTFACE_ROOT/recognition/datasets/. Each training dataset includes at least following 6 files:
    faces_emore/
       train.idx
       train.rec
       property
       lfw.bin
       cfp_fp.bin
       agedb_30.bin

The first three files are the training dataset while the last three files are verification sets.

  1. Train deep face recognition models. In this part, we assume you are in the directory $INSIGHTFACE_ROOT/recognition/ArcFace/.

Place and edit config file:

cp sample_config.py config.py
vim config.py # edit dataset path etc..

We give some examples below. Our experiments were conducted on the Tesla P40 GPU.

(1). Train ArcFace with LResNet100E-IR.

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r100 --loss arcface --dataset emore

It will output verification results of LFW, CFP-FP and AgeDB-30 every 2000 batches. You can check all options in config.py. This model can achieve LFW 99.83+ and MegaFace 98.3%+.

(2). Train CosineFace with LResNet50E-IR.

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r50 --loss cosface --dataset emore

(3). Train Softmax with LMobileNet-GAP.

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss softmax --dataset emore

(4). Fine-turn the above Softmax model with Triplet loss.

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss triplet --lr 0.005 --pretrained ./models/m1-softmax-emore,1

(5). Training in model parallel acceleration.

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train_parall.py --network r100 --loss arcface --dataset emore
  1. Verification results.

LResNet100E-IR network trained on MS1M-Arcface dataset with ArcFace loss:

Method LFW(%) CFP-FP(%) AgeDB-30(%)
Ours 99.80+ 98.0+ 98.20+

Pretrained Models

You can use $INSIGHTFACE_ROOT/recognition/arcface_torch/eval/verification.py to test all the pre-trained models.

Please check Model-Zoo for more pretrained models.

Verification Results on Combined Margin

A combined margin method was proposed as a function of target logits value and original θ:

COM(θ) = cos(m_1*θ+m_2) - m_3

For training with m1=1.0, m2=0.3, m3=0.2, run following command:

CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r100 --loss combined --dataset emore

Results by using MS1M-IBUG(MS1M-V1)

Method m1 m2 m3 LFW CFP-FP AgeDB-30
W&F Norm Softmax 1 0 0 99.28 88.50 95.13
SphereFace 1.5 0 0 99.76 94.17 97.30
CosineFace 1 0 0.35 99.80 94.4 97.91
ArcFace 1 0.5 0 99.83 94.04 98.08
Combined Margin 1.2 0.4 0 99.80 94.08 98.05
Combined Margin 1.1 0 0.35 99.81 94.50 98.08
Combined Margin 1 0.3 0.2 99.83 94.51 98.13
Combined Margin 0.9 0.4 0.15 99.83 94.20 98.16

Test on MegaFace

Please check $INSIGHTFACE_ROOT/evaluation/megaface/ to evaluate the model accuracy on Megaface. All aligned images were already provided.

512-D Feature Embedding

In this part, we assume you are in the directory $INSIGHTFACE_ROOT/deploy/. The input face image should be generally centre cropped. We use RNet+ONet of MTCNN to further align the image before sending it to the feature embedding network.

  1. Prepare a pre-trained model.
  2. Put the model under $INSIGHTFACE_ROOT/models/. For example, $INSIGHTFACE_ROOT/models/model-r100-ii.
  3. Run the test script $INSIGHTFACE_ROOT/deploy/test.py.

For single cropped face image(112x112), total inference time is only 17ms on our testing server(Intel E5-2660 @ 2.00GHz, Tesla M40, LResNet34E-IR).

Third-party Re-implementation

Face Detection

RetinaFace

RetinaFace is a practical single-stage SOTA face detector which is initially introduced in arXiv technical report and then accepted by CVPR 2020. We provide training code, training dataset, pretrained models and evaluation scripts.

demoimg1

Please check RetinaFace for detail.

RetinaFaceAntiCov

RetinaFaceAntiCov is an experimental module to identify face boxes with masks. Please check RetinaFaceAntiCov for detail.

demoimg1

Face Alignment

DenseUNet

Please check the Menpo Benchmark and our Dense U-Net for detail. We also provide other network settings such as classic hourglass. You can find all of training code, training dataset and evaluation scripts there.

CoordinateReg

On the other hand, in contrast to heatmap based approaches, we provide some lightweight facial landmark models with fast coordinate regression. The input of these models is loose cropped face image while the output is the direct landmark coordinates. See detail at alignment-coordinateReg. Now only pretrained models available.

imagevis
videovis

Citation

If you find InsightFace useful in your research, please consider to cite the following related papers:

@inproceedings{deng2019retinaface,
title={RetinaFace: Single-stage Dense Face Localisation in the Wild},
author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos},
booktitle={arxiv},
year={2019}
}

@inproceedings{guo2018stacked,
  title={Stacked Dense U-Nets with Dual Transformers for Robust Face Alignment},
  author={Guo, Jia and Deng, Jiankang and Xue, Niannan and Zafeiriou, Stefanos},
  booktitle={BMVC},
  year={2018}
}

@article{deng2018menpo,
  title={The Menpo benchmark for multi-pose 2D and 3D facial landmark localisation and tracking},
  author={Deng, Jiankang and Roussos, Anastasios and Chrysos, Grigorios and Ververas, Evangelos and Kotsia, Irene and Shen, Jie and Zafeiriou, Stefanos},
  journal={IJCV},
  year={2018}
}

@inproceedings{deng2018arcface,
title={ArcFace: Additive Angular Margin Loss for Deep Face Recognition},
author={Deng, Jiankang and Guo, Jia and Niannan, Xue and Zafeiriou, Stefanos},
booktitle={CVPR},
year={2019}
}

Contact

[Jia Guo](guojia[at]gmail.com)
[Jiankang Deng](jiankangdeng[at]gmail.com)
This repository contains the DendroMap implementation for scalable and interactive exploration of image datasets in machine learning.

DendroMap DendroMap is an interactive tool to explore large-scale image datasets used for machine learning. A deep understanding of your data can be v

DIV Lab 33 Dec 30, 2022
Causal-BALD: Deep Bayesian Active Learning of Outcomes to Infer Treatment-Effects from Observational Data.

causal-bald | Abstract | Installation | Example | Citation | Reproducing Results DUE An implementation of the methods presented in Causal-BALD: Deep B

OATML 13 Oct 07, 2022
"Structure-Augmented Text Representation Learning for Efficient Knowledge Graph Completion"(WWW 2021)

STAR_KGC This repo contains the source code of the paper accepted by WWW'2021. "Structure-Augmented Text Representation Learning for Efficient Knowled

Bo Wang 60 Dec 26, 2022
A dead simple python wrapper for darknet that works with OpenCV 4.1, CUDA 10.1

What Dead simple python wrapper for Yolo V3 using AlexyAB's darknet fork. Works with CUDA 10.1 and OpenCV 4.1 or later (I use OpenCV master as of Jun

Pliable Pixels 6 Jan 12, 2022
Geometric Deep Learning Extension Library for PyTorch

Documentation | Paper | Colab Notebooks | External Resources | OGB Examples PyTorch Geometric (PyG) is a geometric deep learning extension library for

Matthias Fey 16.5k Jan 08, 2023
Offical implementation of Shunted Self-Attention via Multi-Scale Token Aggregation

Shunted Transformer This is the offical implementation of Shunted Self-Attention via Multi-Scale Token Aggregation by Sucheng Ren, Daquan Zhou, Shengf

156 Dec 27, 2022
An official implementation of "Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation" (ICCV 2021) in PyTorch.

Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation This is an official implementation of the paper "Exploiting a Joint

CV Lab @ Yonsei University 35 Oct 26, 2022
ACV is a python library that provides explanations for any machine learning model or data.

ACV is a python library that provides explanations for any machine learning model or data. It gives local rule-based explanations for any model or data and different Shapley Values for tree-based mod

Salim Amoukou 85 Dec 27, 2022
Chainer Implementation of Semantic Segmentation using Adversarial Networks

Semantic Segmentation using Adversarial Networks Requirements Chainer (1.23.0) Differences Use of FCN-VGG16 instead of Dilated8 as Segmentor. Caution

Taiki Oyama 99 Jun 28, 2022
Multi-Glimpse Network With Python

Multi-Glimpse Network Our code requires Python ≥ 3.8 Installation For example, venv + pip: $ python3 -m venv env $ source env/bin/activate (env) $ pyt

9 May 10, 2022
This repository includes different versions of the prescribed-time controller as Simulink blocks and MATLAB script codes for engineering applications.

Prescribed-time Control Prescribed-time control (PTC) blocks in Simulink environment, MATLAB R2020b. For more theoretical details, refer to the papers

Amir Shakouri 1 Mar 11, 2022
Pca-on-genotypes - Mini bioinformatics project - PCA on genotypes

Mini bioinformatics project: PCA on genotypes This repo contains the code from t

Maria Nattestad 8 Dec 04, 2022
The official code repo of "HTS-AT: A Hierarchical Token-Semantic Audio Transformer for Sound Classification and Detection"

Hierarchical Token Semantic Audio Transformer Introduction The Code Repository for "HTS-AT: A Hierarchical Token-Semantic Audio Transformer for Sound

Knut(Ke) Chen 134 Jan 01, 2023
Log4j JNDI inj. vuln scanner

Log-4-JAM - Log 4 Just Another Mess Log4j JNDI inj. vuln scanner Requirements pip3 install requests_toolbelt Usage # make sure target list has http/ht

Ashish Kunwar 66 Nov 09, 2022
CVPR 2021 Challenge on Super-Resolution Space

Learning the Super-Resolution Space Challenge NTIRE 2021 at CVPR Learning the Super-Resolution Space challenge is held as a part of the 6th edition of

andreas 104 Oct 26, 2022
A python package simulating the quasi-2D pseudospin-1/2 Gross-Pitaevskii equation with NVIDIA GPU acceleration.

A python package simulating the quasi-2D pseudospin-1/2 Gross-Pitaevskii equation with NVIDIA GPU acceleration. Introduction spinor-gpe is high-level,

2 Sep 20, 2022
Einshape: DSL-based reshaping library for JAX and other frameworks.

Einshape: DSL-based reshaping library for JAX and other frameworks. The jnp.einsum op provides a DSL-based unified interface to matmul and tensordot o

DeepMind 62 Nov 30, 2022
Image Deblurring using Generative Adversarial Networks

DeblurGAN arXiv Paper Version Pytorch implementation of the paper DeblurGAN: Blind Motion Deblurring Using Conditional Adversarial Networks. Our netwo

Orest Kupyn 2.2k Jan 01, 2023
OpenMMLab Detection Toolbox and Benchmark

MMDetection is an open source object detection toolbox based on PyTorch. It is a part of the OpenMMLab project.

OpenMMLab 22.5k Jan 05, 2023
Semantic Segmentation for Real Point Cloud Scenes via Bilateral Augmentation and Adaptive Fusion (CVPR 2021)

Semantic Segmentation for Real Point Cloud Scenes via Bilateral Augmentation and Adaptive Fusion (CVPR 2021) This repository is for BAAF-Net introduce

90 Dec 29, 2022