Giter VIP home page Giter VIP logo

timobolkart / tempeh Goto Github PK

View Code? Open in Web Editor NEW
112.0 8.0 7.0 9.53 MB

TEMPEH reconstructs 3D heads in dense semantic correspondence from calibrated multi-view images in about 0.3 seconds.

Home Page: https://tempeh.is.tue.mpg.de

License: Other

Python 94.46% Shell 3.48% Makefile 1.02% Batchfile 1.04%
3d-face-reconstruction 3d-mesh 3d-mesh-recovery 3d-reconstruction cvpr2022 face-alignment flame flame-model head-model multi-view-stereo

tempeh's Introduction

Instant Multi-View Head Capture through Learnable Registration

Timo Bolkart · Tianye Li · Michael J. Black

CVPR 2023

This repository is the official implementation of the CVPR 2023 paper Instant Multi-View Head Capture through Learnable Registration.

TEMPEH: Given calibrated multi-view images (top: 4 of 16 views; contrast enhanced for visualization), TEMPEH directly infers 3D head meshes in dense semantic correspondence (bottom) in about 0.3 seconds. TEMPEH reconstructs heads with varying expressions (left) and head poses (right) for subjects unseen during training. Applied to multi-view video input, the frame-by-frame inferred meshes are temporally coherent, making them directly applicable to full-head performance-capture applications.

Paper PDF Sup. Mat. PDF Youtube Video Project Page PyTorch

TL;DR

  • TEMPEH reconstructs 3D heads in semantic correspondence (i.e., in FLAME mesh topology) directly from calibrated multi-view images.
  • Predicting one head takes about 0.3 seconds.
  • TEMPEH leverages ToFu's volumetric feature sampling framework.
  • Self-supervised training from scans overcomes ambiguous correspondence across subjects and imperfect correspondence across expressions.
  • A spatial transformer module localizes the head in the feature volume, which enables the handling of a large capture volumes by focusing on the region of interest.
  • A surface-aware feature fusion accounts for self-occlusions.

Video

Setup

Installing TEMPEH

TEMPEH is tested in a Python 3.7 environment with PyTorch 1.12.1 for CUDA 11.6.

Set up and activate the virtual environment:

# Set up virtualenv
mkdir <your_home_dir>/.virtualenvs
python3.7 -m venv <your_home_dir>/.virtualenvs/TEMPEH

# Activate virtualenv 
cd TEMPEH
source <your_home_dir>/.virtualenvs/TEMPEH/bin/activate

Adjust the pip version (higher pip versions result in errors in the later MPI-IS/mesh installation) and append the current working directory:

pip install -U pip==22.0.4
echo $(pwd) >> <your_home_dir>/.virtualenvs/TEMPEH/lib/python3.7/site-packages/tempeh.pth

Install a PyTorch and Kaolin version that suit you. We tested with PyTorch 1.12.1 and Kaolin 1.13.

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install kaolin==0.13.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-1.12.1_cu116.html

Install mesh processing libraries from MPI-IS/mesh within the virtual environment.

Install the liegroups:

cd modules/liegroups && python setup.py install && cd -

Install the remaining requirements with:

pip install -r requirements.txt

Data

We provide the trained models, test and training set of the FaMoS dataset. For the datasets, you must register at https://tempeh.is.tue.mpg.de/ and agree to the TEMPEH license terms. Then you can use your login credential to download the datasets with the following scripts.

Data for testing

Pretrained models

Fetch the pre-trained TEMPEH coarse (700 MB) and refinement models (600 MB) with:

./fetch_TEMPEH_models.sh

Running this will download the models into './data/downloads' and then extract them to './runs/coarse' and './runs/refinement'.

Example FaMoS test set

For downloading a small test set containing the data shown in the paper, run:

./fetch_test_subset.sh

Running this will download the data into './data/downloads' and then extract the data to './data/test_data_subset'.

Full FaMoS test set

For downloading the entire FaMoS test dataset (18 GB), run:

./fetch_test_data.sh

Running this will download the data into './data/downloads' and then extract the data to './data/test_data'. The archives are extrated with 7z which must be installed prior to running the script.

Data for training

For downloading the FaMoS training dataset (images: 194 GB, scans: 205 GB, registrations: 86 GB), run:

./fetch_training_data.sh

Running this will download the training data into './data/downloads' (default) and then extract the data to './data/training_data' (default). To specifify different download and data directories, edit the 'fetch_training_data.sh' script. Extracting all data requires about 500 GB of disk space. After running the script, ensure that all data packages are successfully downloaded, and that the extraction of the data was successful.

To download only images, scans, or registrations, run either of the following:

./fetch_training_image.sh
./fetch_training_scans.sh
./fetch_registrations.sh

Demo

TEMPEH predicts 3D faces from multi-view images in two stages, a coarse stage followed by a geometry refinement. We provide testing and training codes for TEMPEH. TEMPEH was tested and trained on a compute unit with a NVIDIA A100-SXM 80 GB GPU and 16 CPU cores.

Testing

Testing TEMPEH requieres about 10 GB of GPU memory.

Step 1: Coarse stage inference

python tester/test_global.py \
--coarse_model_run_dir './runs/coarse/coarse__TEMPEH_final' \
--data_list_fname './data/test_data_subset/paper_test_frames.json' \
--image_directory './data/test_data_subset/test_subset_images_4' \
--calibration_directory './data/test_data_subset/test_subset_calibrations' \
--out_dir './results/FaMoS_test_subset/coarse__TEMPEH_final'

Step 2: Refinement stage inference

python tester/test_local.py \
--refinement_model_run_dir './runs/refinement/refinement_TEMPEH_final' \
--data_list_fname './data/test_data_subset/paper_test_frames.json' \
--coarse_prediction_root_dir './results/FaMoS_test_subset/coarse__TEMPEH_final' \
--image_directory './data/test_data_subset/test_subset_images_4' \
--calibration_directory './data/test_data_subset/test_subset_calibrations' \
--out_dir './results/FaMoS_test_subset/refinement__TEMPEH_final'
Training

Training TEMPEH requieres about 20/37 GB (coarse stage/refinement) of GPU memory.

Step 1: Coarse stage training - Part 1

TEMPEH's coarse model is firstly pre-trained fully-supervised with a vertex-to-vertex loss for 300K iterations. Adapt the paths for the training data train-data-list-fname, val-data-list-fname, scan-directory, processed-directory, image-directory, calibration-directory in the option_handler/train_options_global.py and run:

python trainer/train_global.py --num-iterations 300000

Step 2: Coarse stage training - Part 2

After pre-training, training TEMPEH additionally minimizes the point-to-surface distance and an edge-based regularization. To resume the training, add the option --config-filename <CONFIG_FNAME> with the config file from pre-training (default: ./runs/coarse/coarse__TEMPEH__<<DATE>>/config.json) and run:

python trainer/train_global.py \
--config-filename <CONFIG_FNAME> \
--num-iterations 800000 \
--weight-points2surface 10.0 \
--weight-edge-regularizer 1.0 \
--point-mask-weights '{"w_point_face": 0.0, "w_point_ears": 0.0, "w_point_eyeballs": 1.0, "w_point_eye_region": 0.0, "w_point_lips": 0.0, "w_point_neck": 0.0, "w_point_nostrils": 0.0, "w_point_scalp": 0.0,"w_point_boundary": 0.0}'

Step 3: Cache coarse training and validation predictions

Prior to training the refinement model, output the predictions for all training and validationd data:

# training data
python tester/test_global.py \
--coarse_model_run_dir './runs/coarse/coarse__TEMPEH__<<DATE>>' \
--data_list_fname './data/training_data/seventy_subj__all_seq_frames_per_seq_40_head_rot_120_train.json' \
--image_directory  './data/training_data/train_images_4' \
--calibration_directory './data/training_data/train_calibrations' \
--out_dir './results/FaMoS_training_predictions'

# validation data
python tester/test_global.py \
--coarse_model_run_dir './runs/coarse/coarse__TEMPEH__<<DATE>' \
--data_list_fname './data/training_data/eight_subj__all_seq_frames_per_seq_5_val.json' \
--image_directory  './data/training_data/train_images_4' \
--calibration_directory './data/training_data/train_calibrations' \
--out_dir './results/FaMoS_training_predictions'

Step 4: Refinement model training

Adapt the paths for the training data train-data-list-fname, val-data-list-fname, scan-directory, processed-directory, image-directory, calibration-directory in the option_handler/train_options_local.py and run:

python trainer/train_local.py \
--global-model-root-dir './runs/coarse/coarse__TEMPEH__<<DATE>>' \
--global-registration-root-dir './results/FaMoS_training_predictions' \
--num-iterations 150000

Logging

Training TEMPEH logs training errors, validation errors, and reconstruction renderings with Tensorboard in ./runs/coarse/coarse__TEMPEH__<<DATE>/logs and ./runs/refinement/refinement__TEMPEH__<<DATE>/logs.

Resuming training

To resume training from a previously saved checkpoint, run python trainer/train_global.py or python trainer/train_local.py with the option --config-filename <CONFIG_FNAME> with the path of the config file of the trained model. This will load all option from the config file and resume the training.

License

Please see the LICENSE for details.

Citation

If you use code or data from this repository please cite:

@inproceedings{Bolkart2023Tempeh,
  title={Instant Multi-View Head Capture through Learnable Registration},
  author={Timo Bolkart and Tianye Li and Michael J. Black},
  booktitle={Conference on Computer Vision and Pattern Recognition (CVPR)},
  pages={768-779},
  year={2023}
}

Acknowledgement

Parts of the implementation of TEMPEH are based on ToFu. Please see the ToFu repository for details on the initial implementation.

tempeh's People

Contributors

rubikplayer avatar timobolkart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tempeh's Issues

How to test on my own data?

Thank you for your impressive work!

I have my own multi-view images captured by Light Stage and have tried to use your pretrained model to generate FLAME heads, but I found that the results are completely garbled. Do I need to train the model by myself even if I want to generate heads with the same topology as yours? Or is the error due to my data not being aligned properly?

Talking Head

Absolutely great work and one of my favorite papers this year! Is there any plan to further expand the dataset or make a new dataset to include dialogue with matching 3D reconstruction? Or possibly utilizing some obstruction to match in the wild dataset?

"mesh_sampler.npz" missed in coarse_TEMPEH_final.zip?

I have download the test data, and unzip "data/downloads/coarse__TEMPEH_final.zip" to "runs/coarse/coarse__TEMPEH_final" , then I try to run the demo, but I can't find mesh_sampler.npz under the "./runs/coarse/coarse__TEMPEH_final/"
mesh_sampler_fname = join(self.directory_output, 'mesh_sampler.npz')
there is a file in "./runs/refinement/refinement_TEMPEH_final" but not in this path "runs/coarse/coarse__TEMPEH_final",is it the same thing, or could you provide the file for us?

FLAME parameters for the registrations

I am trying to repose the sequences of the registered meshes in your dataset onto FLAME models with different shapes, for which I need facial expression parameters. However, in the downloaded "FLAME Registrations - Package 01 - 07" I can only find the .ply meshes. Where can I find the corresponding FLAME parameters?

about the TEMPEH data

We have noticed variations in the orientation of different expressions among individuals in the downloaded data. This has caused challenges in processing and analyzing the data. We would like to inquire whether there is an aligned version of the data available.

Generalization ability

Impressive work!Can I use your pre-train model to test my own data or I need to train it myself?

Sparse Tensor Error!

@TimoBolkart
I am getting this error, when trying to run the coarse stage inference:

loaded pretrained
resume_checkpoint(): found 1 models
Resuming progress from 600001 iteration
from model path ./runs/coarse\coarse__TEMPEH_final\checkpoints\model_00600000.pth
Traceback (most recent call last):
File "tester/test_global.py", line 78, in
Traceback (most recent call last):
File "", line 1, in
main()
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\spawn.py", line 105, in spawn_main
File "tester/test_global.py", line 75, in main
exitcode = _main(fd)
calibration_directory=calibration_directory, image_file_ext=image_file_ext, out_dir=out_dir)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\spawn.py", line 115, in _main
File "tester/test_global.py", line 53, in run
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
execute_locally(test_config_fname)
File "tester/test_global.py", line 28, in execute_locally
run(config_fname=test_config_fname)
File "C:\GANs\TEMPEH\tester\global_tester.py", line 292, in run
tester.run()
File "C:\GANs\TEMPEH\tester\global_tester.py", line 120, in run
for data in self.dataloader:
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\site-packages\torch\utils\data\dataloader.py", line 444, in iter
return self._get_iterator()
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\site-packages\torch\utils\data\dataloader.py", line 390, in _get_iterator
return _MultiProcessingDataLoaderIter(self)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\site-packages\torch\utils\data\dataloader.py", line 1077, in init
w.start()
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\process.py", line 112, in start
self._popen = self._Popen(self)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\popen_spawn_win32.py", line 89, in init
reduction.dump(process_obj, to_child)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\site-packages\torch\multiprocessing\reductions.py", line 142, in reduce_tensor
storage = tensor.storage()
File "C:\Users\RonniAdavattathuInno\anaconda3\envs\TEMPEH\lib\site-packages\torch_tensor.py", line 205, in storage
return torch._TypedStorage(wrap_storage=self._storage(), dtype=self.dtype)
NotImplementedError: Cannot access storage of SparseTensorImpl

testing with our own data

Thank you for your impressive work!

I want to apply our data, multiple images (same img size as your project ) and same format calibration data(*.tka) used in your project ,to your test code with pre-trained model.
However the generated results, the generated mesh looks crash.
Is there anything I should be careful about?

Thanks

FLAME parameters for the registered dataset.

Hi,

I would be interested on having the FLAME parameters for our dataset, however, when I downloaded the "FLAME Registrations" I can only find the final reconstructions. Would it be possible to get those parameters? I am trying to repose the sequences of the registered meshes onto FLAME models with different shapes.

Thanks!!

Replacement of MPI-IS/mesh?

I am trying to run tempeh in windows and the installation of the mesh viewer from MPI-IS/mesh is not getting installed on windows, and also starts giving away too many errors. Is there any replacement for the mesh viewer maybe making use of meshlab in this case? but I am new to this, don't know how to replace the "Mesh" class that you are using from psbody.mesh with meshlab? Please let me know if there is some alternative to this?

Thanks for the great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.