Awesome
<!-- # EMOCA --> <h1 align="center">EMOCA: Emotion Driven Monocular Face Capture and Animation</h1> <p align="center"> <p align="center"> <a href="https://ps.is.tuebingen.mpg.de/person/rdanecek"><strong>Radek Daněček</strong></a> · <a href="https://ps.is.tuebingen.mpg.de/person/black"><strong>Michael J. Black</strong></a> · <a href="https://sites.google.com/site/bolkartt"><strong>Timo Bolkart</strong></a> </p> <h2 align="center">CVPR 2022</h2> <div align="center"> </div> <!-- <a href=""> <img src="./assets/teaser.jpeg" alt="Logo" width="100%"> </a> -->This repository is the official implementation of the CVPR 2022 paper EMOCA: Emotion-Driven Monocular Face Capture and Animation.
Please check out the inferno library for a much superior face reconstruction network. You can find it in its FaceReconstruction module.
<!-- <p align="center"> <img src="gdl_apps/EMOCA/EMOCA_gif_sparse_det.gif"> <img src="gdl_apps/EMOCA/EMOCA_gif_sparse_rec.gif"> </p> --> <p align="center"> <img src="gdl_apps/EMOCA/EMOCA_gif_sparse_det_rec.gif"> </p> <p align="center"> <img src="gdl_apps/EMOCA/emoca.png"> </p> <p align="center">Top row: input images. Middle row: coarse shape reconstruction. Bottom row: reconstruction with detailed displacements.<p align="center"> <p align="center"> <br> <a href="https://pytorch.org/get-started/locally/"><img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-ee4c2c?logo=pytorch&logoColor=white"></a> <a href="https://pytorchlightning.ai/"><img alt="Lightning" src="https://img.shields.io/badge/-Lightning-792ee5?logo=pytorchlightning&logoColor=white"></a> <a href='https://emoca.is.tue.mpg.de/' style='padding-left: 0.5rem;'> <img src='https://img.shields.io/badge/Project-Page-blue?style=flat&logo=Google%20chrome&logoColor=blue' alt='Project Page'></a> <a href='https://youtu.be/zjMLB2-dVGw' style='padding-left: 0.5rem;'> <img src='https://img.shields.io/badge/Youtube-Video-red?style=flat&logo=youtube&logoColor=red' alt='Youtube Video'> </a> <a href='https://ps.is.mpg.de/uploads_file/attachment/attachment/686/EMOCA__CVPR22.pdf'> <img src='https://img.shields.io/badge/Paper-PDF-green?style=flat&logo=arXiv&logoColor=green' alt='Paper PDF'> </a> </p>EMOCA takes a single in-the-wild image as input and reconstructs a 3D face with sufficient facial expression detail to convey the emotional state of the input image. EMOCA advances the state-of-the-art monocular face reconstruction in-the-wild, putting emphasis on accurate capture of emotional content. The official project page is here.
!!! UPDATE !!!
EMOCA is now deprecated. For a better face reconstruction system, please head over to the inferno libarary and head over to FaceReconstruction project.
!!! UPDATE !!!
EMOCA v2 is now out. Complete the installation steps below and go to EMOCA to test the demos.
Compared to the original model it produces:
- Much better lip and eye alignment
- Much better lip articulation
You can find the comparison video here
This is achieved by:
- Using a subset of mediapipe landmarks for mouth, eyes and eyebrows (as opposed to FAN landmarks that EMOCA v1 uses)
- Using absolute landmark loss in combination with the relative losses (as opposed to only relative landmark losses in EMOCA v1)
- Incorporating perceptual lip reading loss. Inspired by spectre. Big shout-out to these guys!
You will have to upgrade to the new environment in order to use EMOCA v2. Please follow the steps bellow to install the package. Then, go to the EMOCA subfolder and follow the steps described there.
While using the new version of this repo is recommended, you can still access the old release here.
EMOCA project
The training and testing script for EMOCA can be found in this subfolder:
Installation
Dependencies
- Install conda
- Clone this repo
Short version
- Run the installation script:
bash install_38.sh
If this ran without any errors, you now have a functioning conda environment with all the necessary packages to run the demos. If you had issues with the installation script, go through the long version of the installation and see what went wrong. Certain packages (especially for CUDA, PyTorch and PyTorch3D) may cause issues for some users.
Long version
- Pull the relevant submodules using:
bash pull_submodules.sh
- Set up a conda environment with one of the provided conda files. I recommend using
conda-environment_py38_cu11_ubuntu.yml
.
You can use mamba to create a conda environment (strongly recommended):
mamba env create python=3.8 --file conda-environment_py38_cu11_ubuntu.yml
but you can also use plain conda if you want (but it will be slower):
conda env create python=3.8 --file conda-environment_py38_cu11_ubuntu.yml
In case the specified pytorch version somehow did not install, try again manually:
mamba install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
Note: If you find the environment has a missing then just conda/mamba
- or pip
- install it and please notify me.
- Activate the environment:
conda activate work38_cu11
- For some reason cython is glitching in the requirements file so install it separately:
pip install Cython==0.29.14
- Install
gdl
using pip install. I recommend using the-e
option and I have not tested otherwise.
pip install -e .
- Verify that previous step correctly installed Pytorch3D
For some people the compilation fails during requirements install and works after. Try running the following separately:
pip install git+https://github.com/facebookresearch/pytorch3d.git@v0.6.2
Pytorch3D installation (which is part of the requirements file) can unfortunately be tricky and machine specific. EMOCA was developed with is Pytorch3D 0.6.2 and the previous command includes its installation from source (to ensure its compatibility with pytorch and CUDA). If it fails to compile, you can try to find another way to install Pytorch3D.
Notes:
- EMOCA was developed with Pytorch 1.12.1 and Pytorch3d 0.6.2 running on CUDA toolkit 11.1.1 with cuDNN 8.0.5. If for some reason installation of these failed on your machine (which can happen), feel free to install these dependencies another way. The most important thing is that version of Pytorch and Pytorch3D match. The version of CUDA is probably less important.
- Some people experience import issues with opencv-python from either pip or conda. If the OpenCV version installed by the automated script does not work for you (i.e. it does not import without errors), try updating with
pip install -U opencv-python
or installing it through other means. The install script installsopencv-python~=4.5.1.48
installed viapip
.
Usage
- Activate the environment:
conda activate work38_cu11
-
For running EMOCA examples, go to EMOCA
-
For running examples of Emotion Recognition, go to EmotionRecognition
Structure
This repo has two subpackages. gdl
and gdl_apps
GDL
gdl
is a library full of research code. Some things are OK organized, some things are badly organized. It includes but is not limited to the following:
models
is a module with (larger) deep learning modules (pytorch based)layers
contains individual deep learning layersdatasets
contains base classes and their implementations for various datasets I had to use at some points. It's mostly image-based datasets with various forms of GT if anyutils
- various tools
The repo is heavily based on PyTorch and Pytorch Lightning.
GDL_APPS
gdl_apps
contains prototypes that use the GDL library. These can include scripts on how to train, evaluate, test and analyze models from gdl
and/or data for various tasks.
Look for individual READMEs in each sub-projects.
Current projects:
Citation
If you use this work in your publication, please cite the following publications:
@inproceedings{EMOCA:CVPR:2021,
title = {{EMOCA}: {E}motion Driven Monocular Face Capture and Animation},
author = {Danecek, Radek and Black, Michael J. and Bolkart, Timo},
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
pages = {20311--20322},
year = {2022}
}
As EMOCA builds on top of DECA and uses parts of DECA as fixed part of the model, please further cite:
@article{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 (ToG), Proc. SIGGRAPH},
volume = {40},
number = {8},
year = {2021},
url = {https://doi.org/10.1145/3450626.3459936}
}
Furthermore, if you use EMOCA v2, please also cite SPECTRE:
@article{filntisis2022visual,
title = {Visual Speech-Aware Perceptual 3D Facial Expression Reconstruction from Videos},
author = {Filntisis, Panagiotis P. and Retsinas, George and Paraperas-Papantoniou, Foivos and Katsamanis, Athanasios and Roussos, Anastasios and Maragos, Petros},
journal = {arXiv preprint arXiv:2207.11094},
publisher = {arXiv},
year = {2022},
}
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 of this license.
Acknowledgements
There are many people who deserve to get credited. These include but are not limited to: Yao Feng and Haiwen Feng and their original implementation of DECA. Antoine Toisoul and colleagues for EmoNet.