Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yfeng95/DECA
DECA: Detailed Expression Capture and Animation (SIGGRAPH 2021)
https://github.com/yfeng95/DECA
3d alignment depth face flame model reconstruction
Last synced: 24 days ago
JSON representation
DECA: Detailed Expression Capture and Animation (SIGGRAPH 2021)
- Host: GitHub
- URL: https://github.com/yfeng95/DECA
- Owner: yfeng95
- License: other
- Created: 2020-04-08T00:51:49.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-23T11:15:26.000Z (over 1 year ago)
- Last Synced: 2024-11-21T03:32:47.420Z (about 1 month ago)
- Topics: 3d, alignment, depth, face, flame, model, reconstruction
- Language: Python
- Homepage:
- Size: 22.4 MB
- Stars: 2,160
- Watchers: 40
- Forks: 426
- Open Issues: 158
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- StarryDivineSky - YadiraF/DECA
README
# DECA: Detailed Expression Capture and Animation (SIGGRAPH2021)
input image, aligned reconstruction, animation with various poses & expressions
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/YadiraF/DECA/blob/master/Detailed_Expression_Capture_and_Animation.ipynb?authuser=1)
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](https://arxiv.org/abs/2012.04012) 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](https://ringnet.is.tue.mpg.de/challenge) benchmark dataset.
## Getting Started
Clone the repo:
```bash
git 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
```bash
pip install -r requirements.txt
```
Or use virtual environment by runing
```bash
bash install_conda.sh
```
For visualization, we use our rasterizer that uses pytorch JIT Compiling Extensions. If there occurs a compiling error, you can install [pytorch3d](https://github.com/facebookresearch/pytorch3d/blob/master/INSTALL.md) instead and set --rasterizer_type=pytorch3d when running the demos.### Usage
1. Prepare data
run script:
```bash
bash fetch_data.sh
```
(Optional for Albedo)
follow the instructions for the [Albedo model](https://github.com/TimoBolkart/BFM_to_FLAME) to get 'FLAME_albedo_from_BFM.npz', put it into ./data2. Run demos
a. **reconstruction**
```bash
python demos/demo_reconstruct.py -i TestSamples/examples --saveDepth True --saveObj True
```
to visualize the predicted 2D landmanks, 3D landmarks (red means non-visible points), coarse geometry, detailed geometry, and depth.
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 --help` for more details.
b. **expression transfer**
```bash
python demos/demo_transfer.py
```
Given an image, you can reconstruct its 3D face, then animate it by tranfering expressions from other images.
Using Meshlab to open the detailed mesh obj file, you can see something like that:
(Thank Soubhik for allowing me to use his face ^_^)
Note that, you need to set '--useTex True' to get full texture.c. for the [teaser gif](https://github.com/YadiraF/DECA/results/teaser.gif) (**reposing** and **animation**)
```bash
python demos/demo_teaser.py
```
More demos and training code coming soon.## Evaluation
DECA (ours) achieves 9% lower mean shape reconstruction error on the [NoW Challenge](https://ringnet.is.tue.mpg.de/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](https://arxiv.org/abs/2012.04012).
## Training
1. Prepare Training Dataa. Download image data
In DECA, we use [VGGFace2](https://arxiv.org/pdf/1710.08092.pdf), [BUPT-Balancedface](http://www.whdeng.cn/RFW/Trainingdataste.html) and [VoxCeleb2](https://www.robots.ox.ac.uk/~vgg/data/voxceleb/vox2.html)b. Prepare label
[FAN](https://github.com/1adrianb/2D-and-3D-face-alignment) to predict 68 2D landmark
[face_segmentation](https://github.com/YuvalNirkin/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.2. Download face recognition trained model
We use the model from [VGGFace2-pytorch](https://github.com/cydonia999/VGGFace2-pytorch) for calculating identity loss,
download [resnet50_ft](https://drive.google.com/file/d/1A94PAAnwk6L7hXdBXLFosB_s0SzEhAFU/view),
and put it into ./data3. Start training
Train from scratch:
```bash
python 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.yml
```
In the yml files, write the right path for 'output_dir' and 'pretrained_modelpath'.
You can also use [released model](https://drive.google.com/file/d/1rp8kdyLPvErw2dTmqtjISRVvQLj6Yzje/view) as pretrained model, then ignor the pretrain step.## Related works:
* for better emotion prediction: [EMOCA](https://github.com/radekd91/emoca)
* for better skin estimation: [TRUST](https://github.com/HavenFeng/TRUST)## 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}
}
```## License
This code and model are available for non-commercial scientific research purposes as defined in the [LICENSE](https://github.com/YadiraF/DECA/blob/master/LICENSE) file.
By downloading and using the code and model you agree to the terms in the [LICENSE](https://github.com/YadiraF/DECA/blob/master/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](https://github.com/soubhiksanyal/FLAME_PyTorch) and [TF_FLAME](https://github.com/TimoBolkart/TF_FLAME) for the FLAME model
- [Pytorch3D](https://pytorch3d.org/), [neural_renderer](https://github.com/daniilidis-group/neural_renderer), [SoftRas](https://github.com/ShichenLiu/SoftRas) for rendering
- [kornia](https://github.com/kornia/kornia) for image/rotation processing
- [face-alignment](https://github.com/1adrianb/face-alignment) for cropping
- [FAN](https://github.com/1adrianb/2D-and-3D-face-alignment) for landmark detection
- [face_segmentation](https://github.com/YuvalNirkin/face_segmentation) for skin mask
- [VGGFace2-pytorch](https://github.com/cydonia999/VGGFace2-pytorch) for identity lossWe would also like to thank other recent public 3D face reconstruction works that allow us to easily perform quantitative and qualitative comparisons :)
[RingNet](https://github.com/soubhiksanyal/RingNet),
[Deep3DFaceReconstruction](https://github.com/microsoft/Deep3DFaceReconstruction/blob/master/renderer/rasterize_triangles.py),
[Nonlinear_Face_3DMM](https://github.com/tranluan/Nonlinear_Face_3DMM),
[3DDFA-v2](https://github.com/cleardusk/3DDFA_V2),
[extreme_3d_faces](https://github.com/anhttran/extreme_3d_faces),
[facescape](https://github.com/zhuhao-nju/facescape)