Code Monkey home page Code Monkey logo

gdna's Introduction

gDNA: Towards Generative Detailed Neural Avatars

Official code release for CVPR 2022 paper gDNA: Towards Generative Detailed Neural Avatars. We propose a model that can generate diverse detailed and animatable 3D humans.

If you find our code or paper useful, please cite as

@inproceedings{chen2022gdna,
      title={gDNA: Towards Generative Detailed Neural Avatars},
      author={Chen, Xu and Jiang, Tianjian and Song, Jie and Yang, Jinlong and Black, Michael J and Geiger, Andreas and Hilliges, Otmar},    
      booktitle   = {IEEE Conf. on Computer Vision and Pattern Recognition (CVPR)},
      year      = {2022}
      }

Note: In the paper we trained our model with two commercial datasets, 3DPeople and RenderPeople. We haven't yet gotten permission to release a generative model trained with 3DPeople. Instead, we release a model trained with RenderPeople only, and also a model trained with a freely accessible dataset THuman2.0. In addition, the list of original training scans from 3DPeople and RenderPeople can be found in lib/dataset/renderpeople_3dpeople.csv in case one wants to buy them.

Quick Start

Clone this repo:

git clone https://github.com/xuchen-ethz/gdna.git
cd gdna

Install environment:

conda env create -f env.yml
conda activate gdna
python setup.py install

Download SMPL models (1.0.0 for Python 2.7 (10 shape PCs)) and move them to the corresponding locations:

mkdir lib/smpl/smpl_model/
mv /path/to/smpl/models/basicModel_f_lbs_10_207_0_v1.0.0.pkl lib/smpl/smpl_model/SMPL_NEUTRAL.pkl

Download our pretrained models and test motion sequences:

sh ./download_data.sh

Run one of the following command and check the result video in outputs/renderpeople/video

"Dancinterpolation": generate a dancing + interpolation sequence

python test.py expname=renderpeople +experiments=fine eval_mode=interp

Disentangled Control: change the coarse shape while keeping other factors fixed

python test.py expname=renderpeople +experiments=fine eval_mode=z_shape

To control other factors, simply change eval_mode=[z_shape|z_detail|betas|thetas].

Random Sampling: generate samples with random poses and latent codes

python test.py expname=renderpeople +experiments=fine eval_mode=sample

THuman2.0 Model: run the following command with desired eval_mode for the model trained with THuman2.0

python test.py expname=thuman  model.norm_network.multires=6 +experiments=fine datamodule=thuman eval_mode=interp

Note that for this dataset we use more frequency components for the positional encoding (model.norm_network.multires=6) due to the rich details in this dataset. Also note that this THuman2.0 model exhibits less body shape (betas) variations bounded by the body shape variations in the training set.

Training

We use THuman2.0 as an example because it's free. The same pipeline works also for commericial datasets, like 3DPeople and RenderPeople which is used to train our orignal model.

Install Additional Dependencies

Install kaolin for fast occupancy query from meshes.

git clone https://github.com/NVIDIAGameWorks/kaolin
cd kaolin
git checkout v0.9.0
python setup.py develop

Prepare Datasets

First, download THuman2.0 dataset following their instructions.

Also download the corresponding SMPL parameters:

wget https://dataset.ait.ethz.ch/downloads/gdna/THuman2.0_smpl.zip
unzip THuman2.0_smpl.zip -d data/

Next, run the pre-processing script to get ground truth occupancy, surface normal and 2D normal maps:

python preprocess.py --tot 1 --id 0

You can run multiple instantces of the script in parallel by simply specifying --tot to be the number of total instances and --id to be the rank of current instance.

Training

Our model is trained in two stages. First, train the coarse model

python train.py expname=coarse datamodule=thuman

This step takes around 12 hours on 4 Quadro RTX 6000 GPUs.

After the first stage finishes, run the following command to precompute 2D-3D correspondences using implicit renderer+ forward skinning

python precompute.py expname=coarse datamodule=thuman agent_tot=1 agent_id=0

This step is optional but highly recommanded because computing 2D-3D correspondences on the fly is very slow. You can run multiple instantces of the script in parallel by simply specifying agent_tot to be the number of total instances and agent_id to be the rank of current instance.

Next, train the fine model

python train.py expname=fine datamodule=thuman +experiments=fine model.norm_network.multires=6

This step takes around 1.5 days on 4 Quadro RTX 6000 GPUs.

Note that for THuman2.0 we recommand more frequency components for the positional encoding (model.norm_network.multires=6) due to the rich details in this dataset but this is optional.

Training logs are available on wandb (registration needed, free of charge).

Inference

Run one of the following command. Note that model.norm_network.multires=6 needs to be modified to be consistent with the training of the fine model.

"Dancinterpolation": generate a dancing + interpolation sequence

python test.py expname=fine +experiments=fine datamodule=thuman eval_mode=interp model.norm_network.multires=6

Disentangled Control: change the coarse shape while keeping other factors fixed

python test.py expname=fine +experiments=fine datamodule=thuman eval_mode=z_shape model.norm_network.multires=6

To control other factors, simply change `eval_mode=[z_shape|z_detail|betas|thetas].

Random Sampling: generate samples with random poses and latent codes

python test.py expname=fine +experiments=fine datamodule=thuman eval_mode=sample model.norm_network.multires=6

The output videos are stored in outputs/fine/video.

More Work on Neural Implicit Avatars

Here are some other works on neural implicit avatars from our group :)

Acknowledgement

We have used codes from other great research work, including IGR, IDR, NASA, DEQ, StyleGAN-Ada, Occupancy Networks, SMPL-X, ML-GSN. We sincerely thank the authors for their awesome work!

gdna's People

Contributors

xuchen-ethz avatar

Stargazers

Fabian Kemper avatar  avatar JT5D avatar  avatar  avatar  avatar  avatar Changmin Jeon avatar  avatar Jhonzhang avatar  avatar  avatar YiChenCityU avatar Duotun Wang avatar Jeff Carpenter avatar XIAOHAN SUN avatar  avatar ZZWENG avatar  avatar Minjun Kang avatar Hang Ye avatar Yufei Liu avatar  avatar Hyunsoo Cha avatar Markus Worchel avatar Haiyu Zhang avatar JustLX avatar Inhee Lee avatar Zhengming Yu avatar Shikai Li avatar Wastoon avatar  avatar Zhen Xu avatar  avatar  avatar Solang Kim avatar  avatar  avatar  avatar L-P Baril avatar Liang Xu avatar LuoJinhao avatar Taeksoo Kim avatar Ni Lixia avatar crash for loneliness avatar Vladislav avatar Jeffrey Castellano avatar  avatar immortal avatar  avatar Gleb Sterkin avatar Nicolas Dedual avatar TaiMing avatar Hollis-7 avatar Bruno Henrique avatar  avatar Non-Creative Folk avatar Zhu Shuai avatar Wendi Chen avatar Sihun Cha avatar  avatar Kirill Zaitsev avatar tpzou avatar Xuanmeng Zhang avatar 조민지_T6162 avatar Chunfeng Song avatar Zerui Chen avatar Sen Liang avatar Feng Liu avatar Siddharth Choudhary avatar Foteini Dervisi avatar  avatar  avatar Siyuan Bian avatar Lukas avatar Udon avatar liheyuan avatar Pyjcsx avatar Benjamin Biggs avatar  avatar Xinyu Zhang avatar  avatar Junjie Wang avatar  avatar 918 avatar Goluck Konuko avatar  avatar Xiaoke Huang avatar Sean O'Mahoney avatar  avatar cvhadessun avatar  avatar ryan avatar Christian J. Mills avatar  avatar xinyachen avatar Chenghong Li avatar Andrey Smorodov avatar Wojciech Zielonka avatar Cao Yukang avatar

Watchers

James Cloos avatar Jimmy Yu avatar  avatar  avatar kevin zhou avatar Vu Tuan Anh avatar Snow avatar Vinayak avatar  avatar Yash Kant avatar  avatar Pyjcsx avatar Jeff / Jianfei Guo avatar Peterou avatar Gan Qijun avatar liheyuan avatar Ansh Mittal avatar  avatar fighting! avatar Nilo RIver avatar ExponentialML avatar Byungjun Kim avatar vivienHu avatar

gdna's Issues

source code release

Hi, chenxu:

My name is xubaobei, Recently, i read your cvpr2022 paper gDNA. It is a great job. I look forward to try it. So when do you release the source code of gNDA?

Best Wishes!
Baobei Xu

Unexpected blank lines for rendered images

Hi, thank you for your great work!!

I've set up the environment using the given 'env.yml', but as I trained the coarse model I noticed there were unusual blank lines in the plotted images for canonical shape like the attached figure. Those blank lines also appear when I generate the given outputs using 'test.py'.

I believe it's the problem with pytorch3D's renderer, but I was wondering whether you've seen similar outputs during your experiments.
If so, would there be a way to fix this problem??

Thank you in advance.

Screenshot from 2022-11-29 21-44-27

Code for fitting Sizer

Hello, I am interested in gDNA. It is a great job. I have tried this code and want to use it to fit scans . So will you release the source code for fitting sizer?

SMPL fitting on 3D scan

Hi, thank you for sharing a great work.

I have a question about SMPL parameters for training data.
I've purchased 3D scan data from RenderPeople and I'm trying to train gDNA from scratch.
How did you get SMPL parameters of RenderPeople dataset?
I can think of the way getting a 3D pose from triangulation of 2D poses from rendered images of multiple views at first, and optimize SMPL parameters of which joints agree with those from the 3D pose.
Is there any better way to get SMPL parameters of 3D scans?

Thank you in advance.

Error occurs when running preprocess.py

When I run python preprocess.py --tot 1 --id 0, the following error occurs. I install gdna following README.md.

An exception occurred in telemetry logging.Disabling telemetry to prevent further exceptions.
Traceback (most recent call last):
  File "/home/xxx/anaconda3/envs/gdna/lib/python3.7/site-packages/iopath/common/file_io.py", line 946, in __log_tmetry_keys
    handler.log_event()
  File "/home/xxx/anaconda3/envs/gdna/lib/python3.7/site-packages/iopath/common/event_logger.py", line 97, in log_event
    del self._evt
AttributeError: _evt

Training-RuntimeError: number of dims don't match in permute

Hi! Thanks for your awesome work! I met a RuntimeError occurs in broyden.py when training. Do you have any idea about this problem? Thanks for your any help.

Traceback (most recent call last):
  File "train.py", line 72, in main
    trainer.fit(model, datamodule=datamodule)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 608, in fit
    call._call_and_handle_interrupt(
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/call.py", line 36, in _call_and_handle_interrupt
    return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/strategies/launchers/subprocess_script.py", line 88, in launch
    return function(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _fit_impl
    self._run(model, ckpt_path=self.ckpt_path)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1112, in _run
    results = self._run_stage()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1191, in _run_stage
    self._run_train()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1214, in _run_train
    self.fit_loop.run()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/fit_loop.py", line 267, in advance
    self._outputs = self.epoch_loop.run(self._data_fetcher)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 213, in advance
    batch_output = self.batch_loop.run(kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 88, in advance
    outputs = self.optimizer_loop.run(optimizers, kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 202, in advance
    result = self._run_optimization(kwargs, self._optimizers[self.optim_progress.optimizer_position])
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 249, in _run_optimization
    self._optimizer_step(optimizer, opt_idx, kwargs.get("batch_idx", 0), closure)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 370, in _optimizer_step
    self.trainer._call_lightning_module_hook(
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1356, in _call_lightning_module_hook
    output = fn(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/core/module.py", line 1742, in optimizer_step
    optimizer.step(closure=optimizer_closure)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/core/optimizer.py", line 169, in step
    step_output = self._strategy.optimizer_step(self._optimizer, self._optimizer_idx, closure, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/strategies/ddp.py", line 280, in optimizer_step
    optimizer_output = super().optimizer_step(optimizer, opt_idx, closure, model, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/strategies/strategy.py", line 234, in optimizer_step
    return self.precision_plugin.optimizer_step(
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/plugins/precision/precision_plugin.py", line 119, in optimizer_step
    return optimizer.step(closure=closure, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/optim/optimizer.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/optim/adam.py", line 92, in step
    loss = closure()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/plugins/precision/precision_plugin.py", line 105, in _wrap_closure
    closure_result = closure()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 149, in __call__
    self._result = self.closure(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 135, in closure
    step_output = self._step_fn()
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 419, in _training_step
    training_step_output = self.trainer._call_strategy_hook("training_step", *kwargs.values())
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1494, in _call_strategy_hook
    output = fn(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/strategies/ddp.py", line 351, in training_step
    return self.model(*args, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 886, in forward
    output = self.module(*inputs[0], **kwargs[0])
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lyk/.conda/envs/gdna/lib/python3.8/site-packages/pytorch_lightning/overrides/base.py", line 98, in forward
    output = self._forward_module.training_step(*inputs, **kwargs)
  File "/home/lyk/gdna/lib/gdna_model.py", line 336, in training_step
    loss = self.training_step_coarse(batch, batch_idx)
  File "/home/lyk/gdna/lib/gdna_model.py", line 247, in training_step_coarse
    outputs = self.forward(batch['pts_d'], batch['smpl_tfs'],  batch['smpl_verts'], cond, eval_mode=False, only_near_smpl=False)
  File "/home/lyk/gdna/lib/gdna_model.py", line 131, in forward
    pts_c, others = self.deformer.forward(pts_d,
  File "/home/lyk/gdna/lib/model/deformer.py", line 69, in forward
    xc_opt, others = self.__search(xd, xc_init, cond, tfs, eval_mode=eval_mode)
  File "/home/lyk/gdna/lib/model/deformer.py", line 253, in __search
    result = broyden(_func, xc_init, J_inv_init, max_steps=self.opt.max_steps)
  File "/home/lyk/gdna/lib/model/broyden.py", line 69, in broyden
    J_inv[ids_val] += u.bmm(vT)
RuntimeError: number of dims don't match in permute

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.