DECA
DECA: Detailed Expression Capture and Animation (SIGGRAPH 2021)
input image, aligned reconstruction, animation with various poses & expressions The project is written primarily in Python, distributed under the Other license, first published in 2020. It has gained significant community traction with 2,495 stars and 491 forks on GitHub. Key topics include: 3d, alignment, depth, face, flame.
DECA: Detailed Expression Capture and Animation (SIGGRAPH2021)
<p align="center"> <img src="TestSamples/teaser/results/teaser.gif"> </p> <p align="center">input image, aligned reconstruction, animation with various poses & expressions<p align="center">This is the official Pytorch implementation of DECA.
DECA reconstructs a 3D head model with detailed facial geometry from a single input image. The resulting 3D head model can be easily animated. Please refer to the arXiv paper for more details.
The main features:
- Reconstruction: produces head pose, shape, detailed face geometry, and lighting information from a single image.
- Animation: animate the face with realistic wrinkle deformations.
- Robustness: tested on facial images in unconstrained conditions. Our method is robust to various poses, illuminations and occlusions.
- Accurate: state-of-the-art 3D face shape reconstruction on the NoW Challenge benchmark dataset.
Getting Started
Clone the repo:
bashgit clone https://github.com/YadiraF/DECA cd DECA
Requirements
- Python 3.7 (numpy, skimage, scipy, opencv)
- PyTorch >= 1.6 (pytorch3d)
- face-alignment (Optional for detecting face)
You can run
Or use virtual environment by runingbashpip install -r requirements.txt
For visualization, we use our rasterizer that uses pytorch JIT Compiling Extensions. If there occurs a compiling error, you can install pytorch3d instead and set --rasterizer_type=pytorch3d when running the demos.bashbash install_conda.sh
Usage
-
Prepare data
run script:
<!-- or manually download data form [FLAME 2020 model](https://flame.is.tue.mpg.de/download.php) and [DECA trained model](https://drive.google.com/file/d/1rp8kdyLPvErw2dTmqtjISRVvQLj6Yzje/view?usp=sharing), and put them in ./data -->bashbash fetch_data.sh(Optional for Albedo)
follow the instructions for the Albedo model to get 'FLAME_albedo_from_BFM.npz', put it into ./data -
Run demos
a. reconstructionbashpython demos/demo_reconstruct.py -i TestSamples/examples --saveDepth True --saveObj Trueto visualize the predicted 2D landmanks, 3D landmarks (red means non-visible points), coarse geometry, detailed geometry, and depth.
<p align="center"> <img src="Doc/images/id04657-PPHljWCZ53c-000565_inputs_inputs_vis.jpg"> </p> <p align="center"> <img src="Doc/images/IMG_0392_inputs_vis.jpg"> </p> You can also generate an obj file (which can be opened with Meshlab) that includes extracted texture from the input image.Please run
python demos/demo_reconstruct.py --helpfor more details.b. expression transfer
bashpython demos/demo_transfer.pyGiven an image, you can reconstruct its 3D face, then animate it by tranfering expressions from other images.
<p align="center"> <img src="Doc/images/soubhik.gif"> </p> (Thank Soubhik for allowing me to use his face ^_^)
Using Meshlab to open the detailed mesh obj file, you can see something like that:Note that, you need to set '--useTex True' to get full texture.
c. for the teaser gif (reposing and animation)
bashpython demos/demo_teaser.pyMore demos and training code coming soon.
Evaluation
DECA (ours) achieves 9% lower mean shape reconstruction error on the NoW Challenge dataset compared to the previous state-of-the-art method.
The left figure compares the cumulative error of our approach and other recent methods (RingNet and Deng et al. have nearly identitical performance, so their curves overlap each other). Here we use point-to-surface distance as the error metric, following the NoW Challenge.
For more details of the evaluation, please check our arXiv paper.
Training
-
Prepare Training Data
a. Download image data
In DECA, we use VGGFace2, BUPT-Balancedface and VoxCeleb2b. Prepare label
FAN to predict 68 2D landmark
face_segmentation to get skin maskc. Modify dataloader
Dataloaders for different datasets are in decalib/datasets, use the right path for prepared images and labels. -
Download face recognition trained model
We use the model from VGGFace2-pytorch for calculating identity loss,
download resnet50_ft,
and put it into ./data -
Start training
Train from scratch:
bashpython main_train.py --cfg configs/release_version/deca_pretrain.yml python main_train.py --cfg configs/release_version/deca_coarse.yml python main_train.py --cfg configs/release_version/deca_detail.ymlIn the yml files, write the right path for 'output_dir' and 'pretrained_modelpath'.
You can also use released model as pretrained model, then ignor the pretrain step.
Related works:
Citation
If you find our work useful to your research, please consider citing:
@inproceedings{DECA:Siggraph2021,
title={Learning an Animatable Detailed {3D} Face Model from In-The-Wild Images},
author={Feng, Yao and Feng, Haiwen and Black, Michael J. and Bolkart, Timo},
journal = {ACM Transactions on Graphics, (Proc. SIGGRAPH)},
volume = {40},
number = {8},
year = {2021},
url = {https://doi.org/10.1145/3450626.3459936}
}
<!-- ## Notes
1. Training code will also be released in the future. -->
License
This code and model are available for non-commercial scientific research purposes as defined in the LICENSE file.
By downloading and using the code and model you agree to the terms in the LICENSE.
Acknowledgements
For functions or scripts that are based on external sources, we acknowledge the origin individually in each file.
Here are some great resources we benefit:
- FLAME_PyTorch and TF_FLAME for the FLAME model
- Pytorch3D, neural_renderer, SoftRas for rendering
- kornia for image/rotation processing
- face-alignment for cropping
- FAN for landmark detection
- face_segmentation for skin mask
- VGGFace2-pytorch for identity loss
We would also like to thank other recent public 3D face reconstruction works that allow us to easily perform quantitative and qualitative comparisons :)
RingNet,
Deep3DFaceReconstruction,
Nonlinear_Face_3DMM,
3DDFA-v2,
extreme_3d_faces,
facescape
Contributors
Showing top 5 contributors by commit count.
