Code Monkey home page Code Monkey logo

vid2avatar's Introduction

Vid2Avatar: 3D Avatar Reconstruction from Videos in the Wild via Self-supervised Scene Decomposition

Official Repository for CVPR 2023 paper Vid2Avatar: 3D Avatar Reconstruction from Videos in the Wild via Self-supervised Scene Decomposition.

Getting Started

  • Clone this repo: git clone https://github.com/MoyGcc/vid2avatar
  • Create a python virtual environment and activate. conda create -n v2a python=3.7 and conda activate v2a
  • Install dependenices. cd vid2avatar, pip install -r requirement.txt and cd code; python setup.py develop
  • Install Kaolin. We use version 0.10.0.
  • Download SMPL model (1.0.0 for Python 2.7 (10 shape PCs)) and move them to the corresponding places:
mkdir code/lib/smpl/smpl_model/
mv /path/to/smpl/models/basicModel_f_lbs_10_207_0_v1.0.0.pkl code/lib/smpl/smpl_model/SMPL_FEMALE.pkl
mv /path/to/smpl/models/basicmodel_m_lbs_10_207_0_v1.0.0.pkl code/lib/smpl/smpl_model/SMPL_MALE.pkl

Download preprocessed demo data

You can quickly start trying out Vid2Avatar with a preprocessed demo sequence including the pre-trained checkpoint. This can be downloaded from Google drive which is originally a video clip provided by NeuMan. Put this preprocessed demo data under the folder data/ and put the folder checkpoints under outputs/parkinglot/.

Training

Before training, make sure that the metaninfo in the data config file /code/confs/dataset/video.yaml does match the expected training video. You can also continue the training by changing the flag is_continue in the model config file code/confs/model/model_w_bg. And then run:

cd code
python train.py

The training usually takes 24-48 hours. The validation results can be found at outputs/.

Test

Run the following command to obtain the final outputs. By default, this loads the latest checkpoint.

cd code
python test.py

3D Visualization

We use AITViewer to visualize the human models in 3D. First install AITViewer: pip install aitviewer imgui==1.4.1, and then run the following command to visualize the canonical mesh (--mode static) or deformed mesh sequence (--mode dynamic):

cd visualization 
python vis.py --mode {MODE} --path {PATH}

Play on custom video

  • We use ROMP to obtain initial SMPL shape and poses: pip install --upgrade simple-romp
  • Install OpenPose as well as the python bindings.
  • Put the video frames under the folder preprocessing/raw_data/{SEQUENCE_NAME}/frames
  • Modify the preprocessing script preprocessing/run_preprocessing.sh accordingly: the data source, sequence name, and the gender. The data source is by default "custom" which will estimate camera intrinsics. If the camera intrinsics are known, it's better if the true camera parameters can be given.
  • Run preprocessing: cd preprocessing and bash run_preprocessing.sh. The processed data will be stored in data/. The intermediate outputs of the preprocessing can be found at preprocessing/raw_data/{SEQUENCE_NAME}/
  • Launch training and test in the same way as above. The metainfo in the data config file /code/confs/dataset/video.yaml should be changed according to the custom video.

Acknowledgement

We have used codes from other great research work, including VolSDF, NeRF++, SMPL-X, Anim-NeRF, I M Avatar and SNARF. We sincerely thank the authors for their awesome work! We also thank the authors of ICON and SelfRecon for discussing experiment.

Related Works

Here are more recent related human body reconstruction projects from our team:

@inproceedings{guo2023vid2avatar,
      title={Vid2Avatar: 3D Avatar Reconstruction from Videos in the Wild via Self-supervised Scene Decomposition},
      author={Guo, Chen and Jiang, Tianjian and Chen, Xu and Song, Jie and Hilliges, Otmar},    
      booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
      month     = {June},
      year      = {2023},
    }

vid2avatar's People

Contributors

moygcc 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  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

vid2avatar's Issues

Please check the test code

Hi again, while I was testing the results, and I found something weird on the code

https://github.com/MoyGcc/vid2avatar/blob/main/code/v2a_model.py#L32C1-L48

class V2AModel(pl.LightningModule):
    def __init__(self, opt) -> None:
        super().__init__()

        self.opt = opt
        num_training_frames = opt.dataset.metainfo.end_frame - opt.dataset.metainfo.start_frame
        self.betas_path = os.path.join(hydra.utils.to_absolute_path('..'), 'data', opt.dataset.metainfo.data_dir, 'mean_shape.npy')
        self.gender = opt.dataset.metainfo.gender
        self.model = V2A(opt.model, self.betas_path, self.gender, num_training_frames)
        self.start_frame = opt.dataset.metainfo.start_frame
        self.end_frame = opt.dataset.metainfo.end_frame
        self.training_modules = ["model"]

        self.training_indices = list(range(self.start_frame, self.end_frame))
        self.body_model_params = BodyModelParams(num_training_frames, model_type='smpl')
        self.load_body_model_params()
        optim_params = self.body_model_params.param_names
        for param_name in optim_params:
            self.body_model_params.set_requires_grad(param_name, requires_grad=True)
        self.training_modules += ['body_model_params']
        
        self.loss = Loss(opt.model.loss)

    def load_body_model_params(self):
        body_model_params = {param_name: [] for param_name in self.body_model_params.param_names}
        data_root = os.path.join('../data', self.opt.dataset.metainfo.data_dir)
        data_root = hydra.utils.to_absolute_path(data_root)

        body_model_params['betas'] = torch.tensor(np.load(os.path.join(data_root, 'mean_shape.npy'))[None], dtype=torch.float32)
        body_model_params['global_orient'] = torch.tensor(np.load(os.path.join(data_root, 'poses.npy'))[self.training_indices][:, :3], dtype=torch.float32)
        body_model_params['body_pose'] = torch.tensor(np.load(os.path.join(data_root, 'poses.npy'))[self.training_indices] [:, 3:], dtype=torch.float32)
        body_model_params['transl'] = torch.tensor(np.load(os.path.join(data_root, 'normalize_trans.npy'))[self.training_indices], dtype=torch.float32)

        for param_name in body_model_params.keys():
            self.body_model_params.init_parameters(param_name, body_model_params[param_name], requires_grad=False) 

I think you should not run self.load_body_model_params() at the test phase.
At the test phase, the body model parameters are already initialized by checkpoint, and If you run this function, the training initial value (stored as a file) will be overwrited, so don't you think you're not going to use the trained pose parameters at the test phase?

Is there anything that I'm missing? Please advise.

Thank you!

Memory Error

Traceback (most recent call last):
  File "test.py", line 36, in main
    trainer.test(model, testset, ckpt_path=checkpoint)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 907, in test
    return self._call_and_handle_interrupt(self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 683, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 950, in _test_impl
    results = self._run(model, ckpt_path=self.tested_ckpt_path)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1195, in _run
    self._dispatch()
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1271, in _dispatch
    self.training_type_plugin.start_evaluating(self)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\plugins\training_type\training_type_plugin.py", line 206, in start_evaluating
    self._results = trainer.run_stage()
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1282, in run_stage
    return self._run_evaluate()
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1330, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\loops\base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\loops\dataloader\evaluation_loop.py", line 110, in advance
    dl_outputs = self.epoch_loop.run(dataloader, dataloader_idx, dl_max_batches, self.num_dataloaders)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\loops\base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\loops\epoch\evaluation_epoch_loop.py", line 122, in advance
    output = self._evaluation_step(batch, batch_idx, dataloader_idx)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\loops\epoch\evaluation_epoch_loop.py", line 213, in _evaluation_step
    output = self.trainer.accelerator.test_step(step_kwargs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\accelerators\accelerator.py", line 244, in test_step
    return self.training_type_plugin.test_step(*step_kwargs.values())
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\pytorch_lightning\plugins\training_type\training_type_plugin.py", line 222, in test_step
    return self.model.test_step(*args, **kwargs)
  File "C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code\v2a_model.py", line 268, in test_step
    model_outputs = self.model(batch_inputs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code\lib\model\v2a.py", line 159, in forward
    cond, smpl_tfs, feature_vectors=feature_vectors, is_training=self.training)
  File "C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code\lib\model\v2a.py", line 237, in get_rbg_value
    _, gradients, feature_vectors = self.forward_gradient(x, pnts_c, cond, tfs, create_graph=is_training, retain_graph=is_training)
  File "C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code\lib\model\v2a.py", line 269, in forward_gradient
    output = self.implicit_network(pnts_c, cond)[0]
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code\lib\model\networks.py", line 104, in forward
    x = lin(x)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\torch\nn\modules\module.py", line 1120, in _call_impl
    result = forward_call(*input, **kwargs)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\torch\nn\modules\linear.py", line 103, in forward
    return F.linear(input, self.weight, self.bias)
  File "C:\Users\freez\anaconda3\envs\vid2avatar\lib\site-packages\torch\nn\functional.py", line 1848, in linear
    return torch._C._nn.linear(input, weight, bias)
RuntimeError: CUDA out of memory. Tried to allocate 196.00 MiB (GPU 0; 8.00 GiB total capacity; 6.83 GiB already allocated; 0 bytes free; 7.15 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Testing:   0%|                                                                                                                                                                                                                                         | 0/42 [00:23<?, ?it/s]

(vid2avatar) C:\Users\freez\Documents\python_Projects\Video2Avatar\vid2avatar\code>nvidia-smi
Sat May 20 14:47:12 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 531.14                 Driver Version: 531.14       CUDA Version: 12.1     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                      TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3050       WDDM | 00000000:09:00.0  On |                  N/A |
|  0%   38C    P8                9W / 130W|   1130MiB /  8192MiB |      3%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

This is a similar issue to #5. However, I'm using an RTX 3050 with 8 GB VRAM. Reducing the sampled pixels doesn't seem to work in my case.

why convert the coordinate system to opengl?

And if I need to rotate the camera around the human to generate a 360-degree cam trajectory,
how should I transform the current extrinsic parameter, do you have any suggestion or reference code?

SynWild Dataset

Are you planning on releasing the dataset you mention you created on the article?

How do you account for the human movement in background modeling?

I noticed that you centered the human bounding box as origin for each frame. In that case, if the human moves, wouldn't the same 3d coordinate represent different locations in the background in different frames? How is this accounted for in background modeling?

ModuleNotFoundError: No module named 'torch.distributed.algorithms.model_averaging'

firstly installed torch 1.9
downgraded to 1.8 after seeing solutions on stack
Current :-
torch==1.8.1+cu111
torchaudio==0.8.1
torchmetrics==1.0.1
torchvision==0.9.1+cu111

Traceback (most recent call last):
  File "train.py", line 1, in <module>
    from v2a_model import V2AModel
  File "/home/prityush/Desktop/avatar/vid2avatar/code/v2a_model.py", line 1, in <module>
    import pytorch_lightning as pl
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/__init__.py", line 35, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/callbacks/__init__.py", line 28, in <module>
    from pytorch_lightning.callbacks.pruning import ModelPruning
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/callbacks/pruning.py", line 31, in <module>
    from pytorch_lightning.core.module import LightningModule
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/core/__init__.py", line 16, in <module>
    from pytorch_lightning.core.module import LightningModule
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/core/module.py", line 53, in <module>
    from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/__init__.py", line 17, in <module>
    from pytorch_lightning.trainer.trainer import Trainer
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 58, in <module>
    from pytorch_lightning.loops import PredictionLoop, TrainingEpochLoop
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/__init__.py", line 15, in <module>
    from pytorch_lightning.loops.batch import TrainingBatchLoop  # noqa: F401
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/batch/__init__.py", line 15, in <module>
    from pytorch_lightning.loops.batch.training_batch_loop import TrainingBatchLoop  # noqa: F401
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 20, in <module>
    from pytorch_lightning.loops.optimization.manual_loop import _OUTPUTS_TYPE as _MANUAL_LOOP_OUTPUTS_TYPE
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/__init__.py", line 15, in <module>
    from pytorch_lightning.loops.optimization.manual_loop import ManualOptimization  # noqa: F401
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/manual_loop.py", line 23, in <module>
    from pytorch_lightning.loops.utilities import _build_training_step_kwargs, _extract_hiddens
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/utilities.py", line 29, in <module>
    from pytorch_lightning.strategies.parallel import ParallelStrategy
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/strategies/__init__.py", line 15, in <module>
    from pytorch_lightning.strategies.bagua import BaguaStrategy  # noqa: F401
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/strategies/bagua.py", line 30, in <module>
    from pytorch_lightning.strategies.ddp import DDPStrategy
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/strategies/ddp.py", line 65, in <module>
    from torch.distributed.algorithms.model_averaging.averagers import ModelAverager
ModuleNotFoundError: No module named 'torch.distributed.algorithms.model_averaging'

test.py CUDA Assertion "index out of bounds"

I had the RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn while running test.py as reported in my #16 and @MoyGcc already answered in #5.

However downgrade to pytorch-lightning==1.5.7 as suggested will prevent me to use train.py because I had to upgrade to pytorch-lightning==1.9.5 to fix an error occuring during training epoch 20, please see this post.

Whatever I'm more interested into running test.py and ultimately on my own video. So I downgraded to pytorch-lightning==1.5.7 and use the @MoyGcc pre-trained checkpoint to run test.py. I got the memory error of #5, so I changed the test.py num_sample from -1 to 256. This gave me the following error:

KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/vizua/vid2avatar/code/lib/datasets/dataset.py", line 186, in __getitem__
    "img_size": images["img_size"]
KeyError: 'img_size'

So I fixed this line of code in dataset.py like this:

#            images = {"rgb": samples["rgb"].astype(np.float32)}
            images = {
                "rgb": samples["rgb"].astype(np.float32),
                "img_size": img_size
            }

Now test.py runs but it fails on a CUDA assertion that I'm unable to fix:

$ python test.py
test.py:9: UserWarning:
The version_base parameter is not specified.
Please specify a compatability version level, or None.
Will assume defaults for version 1.1
  @hydra.main(config_path="confs", config_name="base")
/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/hydra.py:127: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default.
See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information.
  configure_logging=with_log_configuration,
Global seed set to 42
Working dir: /home/vizua/vid2avatar/outputs/Video/parkinglot
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
Restoring states from the checkpoint path at checkpoints/epoch=6299-loss=0.01887552998960018.ckpt
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Loaded model weights from checkpoint at checkpoints/epoch=6299-loss=0.01887552998960018.ckpt
Testing: 0it [00:00, ?it/s]/home/vizua/vid2avatar/code/v2a_model.py:219: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  1) // pixel_per_batch
mise.MISE(32, 4, 0):
points shape: 35937
points: []
/home/vizua/vid2avatar/code/lib/utils/meshing.py:49: FutureWarning: marching_cubes_lewiner is deprecated in favor of marching_cubes. marching_cubes_lewiner will be removed in version 0.19
  level=level_set)
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [6,0,0], thread: [96,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [6,0,0], thread: [97,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.

.................................................................................

/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [3,0,0], thread: [93,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [3,0,0], thread: [94,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [3,0,0], thread: [95,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
Error executing job with overrides: []
Traceback (most recent call last):
  File "test.py", line 39, in <module>
    main()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/main.py", line 99, in decorated_main
    config_name=config_name,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 401, in _run_hydra
    overrides=overrides,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 458, in _run_app
    lambda: hydra.run(
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 461, in <lambda>
    overrides=overrides,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "test.py", line 36, in main
    trainer.test(model, testset, ckpt_path=checkpoint)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 907, in test
    return self._call_and_handle_interrupt(self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 683, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 950, in _test_impl
    results = self._run(model, ckpt_path=self.tested_ckpt_path)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1195, in _run
    self._dispatch()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1271, in _dispatch
    self.training_type_plugin.start_evaluating(self)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 206, in start_evaluating
    self._results = trainer.run_stage()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1282, in run_stage
    return self._run_evaluate()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1330, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 110, in advance
    dl_outputs = self.epoch_loop.run(dataloader, dataloader_idx, dl_max_batches, self.num_dataloaders)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 122, in advance
    output = self._evaluation_step(batch, batch_idx, dataloader_idx)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 213, in _evaluation_step
    output = self.trainer.accelerator.test_step(step_kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/accelerators/accelerator.py", line 244, in test_step
    return self.training_type_plugin.test_step(*step_kwargs.values())
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 222, in test_step
    return self.model.test_step(*args, **kwargs)
  File "/home/vizua/vid2avatar/code/v2a_model.py", line 250, in test_step
    batch_inputs = {"uv": inputs["uv"][:, indices],
RuntimeError: CUDA error: device-side assert triggered
Testing:   0%|          | 0/42 [00:06<?, ?it/s]

N.B: I have the exact same issue with owned trained model at epoch 800 with pytorch-lightning==1.9.5

Hand + face Pose Guide to generate

Hi,
Is it possible to generate a single character from the Pose for about 5 seconds?

I have a video of Pose ( openpose + hands + face) and i was wondering if it is possible to generate an output video withe the length of 5 seconds that has a consistent character/Avatar which plays Dance, .... from the controled (pose) input?

i want to generate human like animation (No matter what, but just a consistent Character/Avatar)
Sample Video

Thanks
Best regards

What openpose model did you use?

Hello, thank you for sharing such great code. I appreciate it. In the run_openpose.py script, you used the OpenPose model, but I noticed that no specific model is specified in the params. I'm curious to know which model you used: body_25, COCO, or MPI?

Also, have you tried training with init pose parameters that do not involve refining with OpenPose? If you have, I'm curious to know if it still converges to good results.

Error while running requirements.txt

Hello, thanks for the great job,
I want to mention that I created my virtualenv and then I run the command : pip install -r requirement.txt
I got an error:
Screenshot from 2023-07-26 12-14-14
I dont know if I done something wrong but I think torch should not be a preliminary for a virtualenv.
Maybe you should fix this because when I installed torch==1.9.1 before run requirements.txt, the installation completed.

Which vertices are used to get index_off_surface?

Which vertices do self.mesh_face_vertices refer to here, vertices in canonical space or in posed space? If I understand your Opacity Sparseness Regularization correctly, you calculate the distances between the deformed sample points in canonical space and the canonical mesh with current SMPL params, and penalize for rays whose closest sampled point is > 5 cm from the mesh. However, this self.mesh_face_vertices comes from self.smpl_server.verts_c which is the output of a SMPL forward pass. This confused me as why would you calculate the distance between canonical points and the posed vertices?

installation problem

Hi! Thanks for your work!
I met some problem when i run the train.py.
I installed all the requirements along the readme and my device is also the 3090
image
Should I install the orther version of torch cause I don't know if it's matter.
Thanks!
image

Can't initialized the environment with given versions

I have been trying to set up the environment as indicated in the README in order to reproduce the results, but I've encountered different conflicts/problems.
The main issue is that I find the versions torch==1.9.1, and torchvision==0.10.1 to be not available for installation. Installing later releases produces conflicts and errors such as the following two:

ModuleNotFoundError: No module named 'torchtext.legacy

OSError: /usr/local/lib/python3.10/dist-packages/torchtext/lib/libtorchtext.so: undefined symbol: _ZN2at4_ops5zeros4callEN3c108ArrayRefINS2_6SymIntEEENS2_8optionalINS2_10ScalarTypeEEENS6_INS2_6LayoutEEENS6_INS2_6DeviceEEENS6_IbEE

I may be getting something wrong but I spent a while trying to figure out versions that would work and thought asking may provide a quicker solution.
Thank you in advance for your support and availability.

tensors does not require grad and does not have a grad_fn

Thanks for your work @MoyGcc and sorry to bother you because my pytorch and deep learning knowledge is quite basic.

After running into some issues details in #13, I'm now able to run train.py. It's now around epoch 700 and I wonder if I'm supposed to let it run until the max epochs defined in train.py e.g 8000 ?

However I tried to run test.py with this trained model at epoch 700. But it complains about element 0 of tensors does not require grad and does not have a grad_fn with the following output:

/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:479: LightningDeprecationWarning: Setting `Trainer(gpus=1)` is deprecated in v1.7 and will be removed in v2.0. Please use `Trainer(accelerator='gpu', devices=1)` instead.
  f"Setting `Trainer(gpus={gpus!r})` is deprecated in v1.7 and will be removed"
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
Restoring states from the checkpoint path at checkpoints/last.ckpt
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Loaded model weights from checkpoint at checkpoints/last.ckpt
Testing DataLoader 0:   0%|                                                                                                                                                     | 0/42 [00:00<?, ?it/s]/home/vizua/vid2avatar/code/v2a_model.py:219: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  1) // pixel_per_batch
/home/vizua/vid2avatar/code/lib/utils/meshing.py:49: FutureWarning: marching_cubes_lewiner is deprecated in favor of marching_cubes. marching_cubes_lewiner will be removed in version 0.19
  level=level_set)
Error executing job with overrides: []
Traceback (most recent call last):
  File "test.py", line 39, in <module>
    main()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/main.py", line 99, in decorated_main
    config_name=config_name,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 401, in _run_hydra
    overrides=overrides,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 458, in _run_app
    lambda: hydra.run(
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/utils.py", line 461, in <lambda>
    overrides=overrides,
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "test.py", line 36, in main
    trainer.test(model, testset, ckpt_path=checkpoint)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 795, in test
    self, self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 842, in _test_impl
    results = self._run(model, ckpt_path=self.ckpt_path)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1112, in _run
    results = self._run_stage()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1188, in _run_stage
    return self._run_evaluate()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1228, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 152, in advance
    dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 137, in advance
    output = self._evaluation_step(**kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 234, in _evaluation_step
    output = self.trainer._call_strategy_hook(hook_name, *kwargs.values())
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1494, in _call_strategy_hook
    output = fn(*args, **kwargs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch_lightning/strategies/strategy.py", line 399, in test_step
    return self.model.test_step(*args, **kwargs)
  File "/home/vizua/vid2avatar/code/v2a_model.py", line 269, in test_step
    model_outputs = self.model(batch_inputs)
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/vizua/vid2avatar/code/lib/model/v2a.py", line 159, in forward
    cond, smpl_tfs, feature_vectors=feature_vectors, is_training=self.training)
  File "/home/vizua/vid2avatar/code/lib/model/v2a.py", line 237, in get_rbg_value
    _, gradients, feature_vectors = self.forward_gradient(x, pnts_c, cond, tfs, create_graph=is_training, retain_graph=is_training)
  File "/home/vizua/vid2avatar/code/lib/model/v2a.py", line 264, in forward_gradient
    only_inputs=True)[0]
  File "/home/vizua/anaconda3/envs/v2a/lib/python3.7/site-packages/torch/autograd/__init__.py", line 236, in grad
    inputs, allow_unused, accumulate_grad=False)
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Is it because my training is not over? If not, do you know what could be wrong please?

Also I expect test.py to produce a 3D animated avatar but could you tell me what's the concrete output format?

Memory requirements

Do you know what is the memory requirements to train and test it?
I was trying and received an memory error
image

I have a RTX 3090 24gb VRAM running on windows.

And, anyway is there some settings that we could try to make it use less memory, to be able to run on our cards?

Thanks a lot!

Problems with visualizaiton in virtual machine

I am executing everything in a virtual machine, after training and testing your "video" example I got all the outputs, 42 canocial PLY meshes and 42 deformed PLY meshes in the outputs/Video/parkinglot/test_mesh,

When I try to visualize the avatar in 3d and run the vis.py python file, I get this error:

**(v2a) jupyter@vid2avatar:~/vid2avatar/visualization$ python vis.py --mode "dynamic" --path "/home/jupyter/vid2avatar/outputs/Video/parkinglot/test_mesh"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted**

I think Qt can only run in a local machine and that's the reason why I can't make it run. https://stackoverflow.com/questions/56491808/could-not-connect-to-any-x-display-google-colab-run-time

Is there any "easy" fix or do I have to run it locally? I do not have a GPU, that's why I was executing it in the cloud.

Thank you for your amazing work.

Is PyTorch3D compatible with the other libraries versions?

I have been setting up a docker image to run the code inside a container, everything is being set up properly (except Kaolin, I have not tested it yet). The image installs everything as indicated, following the versions you propose.
However, installing PyTorch3D is giving me problems. I have tested all the different install options proposed in https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md and none of them succeeded in building the wheel for PyTorch3D. Looking at the required versions for PyTorch3D on the above mentioned page, they say the following are needed:

Requirements
Core library

Linux or macOS or Windows
Python 3.8, 3.9 or 3.10
PyTorch 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 2.0.0 or 2.0.1.

torchvision that matches the PyTorch installation. You can install them together as explained at pytorch.org to make sure of this.
gcc & g++ ≥ 4.9
fvcore
ioPath
If CUDA is to be used, use a version which is supported by the corresponding pytorch version and at least version 9.2.
If CUDA older than 11.7 is to be used and you are building from source, the CUB library must be available. We recommend version 1.10.0.

In particular, Python 3.7 and PyTorch 1.9.1 seem to not be supported. Am I doing something wrong and there is a simple solution? Or should I use compatible versions of Python and PyTorch risking errors in the code?
For completeness, I am sharing also the Dockerfile I am using in order to set everything up:

# --------------------------------------------------------------------------------------------------------------------
# Keep in mind that the image needs to be run with: $ docker run -it --pgus all if3d_image 
# If changes are not being included in the build use $ docker build --no-cache -t if3d_image . 
# --------------------------------------------------------------------------------------------------------------------

# Build the container using the CUDA toolkit version 11.1 image as the base image
FROM nvidia/cuda:11.1.1-devel-ubuntu20.04

# Fetch the keys that are missing from the cuda base image 
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub

# For more details on the installation refere to https://saturncloud.io/blog/how-to-use-gpus-inside-docker-containers-resolving-cuda-version-and-torchcudaisavailable-issues/
# Also, refere to https://www.howtogeek.com/devops/how-to-use-an-nvidia-gpu-with-docker-containers/
RUN apt-get update && apt-get install -y --no-install-recommends \
    cuda-cudart-11-1 \
    && rm -rf /var/lib/apt/lists/*

# Install general dependecies
RUN apt-get update && \
    apt-get install -y \
    python3.7 \
    python3-pip \
    build-essential \
    git 
    #nvidia-docker2 || I don't know if this one is necessary. It should be tested when run on the servers

# Upgrade pip (this is necessary otherwise the installation of setuptools gives problems for some versions)
RUN python3 -m pip install --upgrade pip

# Set environment variables
ENV FORCE_CUDA=1

# Clone the IF3D repository. 
RUN git clone https://huggingface.co/spaces/leobcc/IF3D

# Change working directory to the project folder
WORKDIR /IF3D

# Install dependencies
RUN pip install -r requirement.txt

# Install the cuda compatible version of torch 1.9.1
RUN pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

# Install PyTorch3D
RUN pip install git+https://github.com/facebookresearch/pytorch3d.git@stable

# Run setup
RUN cd code; python3 setup.py develop; cd ..

# Install Kaolin (version 0.10.0)
#RUN git clone --recursive https://github.com/NVIDIAGameWorks/kaolin \
#    && cd kaolin \
#    && git checkout v0.10.0 \
#    && python setup.py develop \
#    && cd ..

Question: Can this be used in real time applications?

First of all, I just wanted to say that I love this tool: it's super accurate and realistic compared to everything else I've seen.
Can this be used in real time applications? If not, are there any plans to enable this?

Many Thanks.

No setup.py

In the readme, it is said to run

python setup.py develop

But no such file exists.

Setting up training dataset

I am having trouble understanding how to set up the dataset, in particular the training data in the folders.
More specifically, I would like to reproduce the results on the 3DPW dataset, which you mention in your paper. I have downloaded the dataset and extracted the imageFiles and the sequenceFiles. I have been trying to figure out from the code how the dataloader is set up, but I have some doubts. Before wasting time on some wrong solution to train the model over this dataset, I though I may ask for some clarifications.

Would you mind give some more insights on how to proceed? (where exactly to put the folders, whether or not to leave them separated in train validation and test, if running the preprocessing is needed for this dataset)

Thank you in advance, I hope the question is not too obvious or out of place.

I can see the vis result using aitviewer, but have OSError: [Errno 32] Broken pipe. when i want to export the video.

Hello!
I can see the video in aitviewer, but failed to export it with following error.
what is the problem and how can i solve it ? Thank you !

Got keys from plugin meta data ("webp")
QFactoryLoader::QFactoryLoader() checking directory path "/home/ouusan/anaconda3/envs/vid2a/bin/imageformats" ...
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqgif.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqicns.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqico.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqjpeg.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqsvg.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqtga.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqtiff.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqwbmp.so"
loaded library "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqwebp.so"
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
Rendering frames: 0%| | 0/600 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/skvideo/io/abstract.py", line 514, in writeFrame
self._proc.stdin.write(vid.tostring())
BrokenPipeError: [Errno 32] Broken Pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ouusan/vid2avatar/visualization/vis.py", line 52, in
vis_dynamic(args)
File "/home/ouusan/vid2avatar/visualization/vis.py", line 32, in vis_dynamic
viewer.run()
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 515, in run
self.window.render(current_time, delta)
File "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/moderngl_window/context/base/window.py", line 713, in render
self.render_func(time, frame_time)
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 563, in render
self.gui()
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 653, in gui
gc()
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 857, in gui_menu
self.gui_export()
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 1083, in gui_export
quality=self.export_quality,
File "/home/ouusan/vid2avatar/aitviewer/aitviewer/viewer.py", line 1760, in export_video
writer.writeFrame(np.array(img))
File "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/skvideo/io/abstract.py", line 519, in writeFrame
raise IOError(msg)
OSError: [Errno 32] Broken Pipe

FFMPEG COMMAND:
/home/ouusan/anaconda3/envs/vid2a/bin/ffmpeg -y -framerate 60.0 -f rawvideo -pix_fmt rgb24 -s 1600x900 -i - -pix_fmt yuv420p -vf pad=ceil(iw/2)*2:ceil(ih/2)*2 -r 60.0 -c:v libx264 -preset slow -profile:v high -level:v 4.0 -crf 23 /home/ouusan/vid2avatar/export/videos/aitviewer_0.mp4

FFMPEG STDERR OUTPUT:

QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqgif.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqicns.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqico.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqjpeg.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqsvg.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqtga.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqtiff.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqwbmp.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/imageformats/libqwebp.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
QLibraryPrivate::unload succeeded on "/home/ouusan/anaconda3/envs/vid2a/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so"
QLibraryPrivate::unload succeeded on "Xcursor" (faked)

Process finished with exit code 1

Render SMPL mesh using transformed/normalized parameters

Wonderful work!
I am trying to render the SMPL mesh along the training process to see their updates. Instead of using volumetric rendering, I am using the same pytorch3d renderer that you used during preprocessing. The only difference is that the rendering you have done at the 'refined' stage during preprocessing relied on unnormalized parameters. However, when I try to render SMPL mesh by using the normalized parameters (cameras, translation) the mesh is a bit off:
h36m_rendering

My workflow is simple:

  1. fetch cameras from 'cameras_normalize.npz', SMPL poses from 'poses.npy', and translation from 'normalize_trans.npy';
  2. unpack K, E, and scale from normalized cameras to initialize renderer;
  3. use SMPL to get the mesh and apply scale to both vertices and trans.
    The above rendering is what I got. Any suggestion is highly appreciated! Thank you!

test.py not working

I have trained a model with my own data, everything worked properly but when I launched the test.py it gave me this error:

Error executing job with overrides: []
Traceback (most recent call last):
  File "test.py", line 36, in main
    trainer.test(model, testset, ckpt_path=checkpoint)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 795, in test
    self, self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 842, in _test_impl
    results = self._run(model, ckpt_path=self.ckpt_path)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1112, in _run
    results = self._run_stage()
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1188, in _run_stage
    return self._run_evaluate()
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1228, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 152, in advance
    dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 137, in advance
    output = self._evaluation_step(**kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 234, in _evaluation_step
    output = self.trainer._call_strategy_hook(hook_name, *kwargs.values())
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1494, in _call_strategy_hook
    output = fn(*args, **kwargs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/pytorch_lightning/strategies/strategy.py", line 399, in test_step
    return self.model.test_step(*args, **kwargs)
  File "/home/user/Desktop/vid2avatar/code/v2a_model.py", line 268, in test_step
    model_outputs = self.model(batch_inputs)
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/user/Desktop/vid2avatar/code/lib/model/v2a.py", line 159, in forward
    cond, smpl_tfs, feature_vectors=feature_vectors, is_training=self.training)
  File "/home/user/Desktop/vid2avatar/code/lib/model/v2a.py", line 237, in get_rbg_value
    _, gradients, feature_vectors = self.forward_gradient(x, pnts_c, cond, tfs, create_graph=is_training, retain_graph=is_training)
  File "/home/user/Desktop/vid2avatar/code/lib/model/v2a.py", line 264, in forward_gradient
    only_inputs=True)[0]
  File "/home/user/anaconda3/envs/vid2avatar/lib/python3.7/site-packages/torch/autograd/__init__.py", line 302, in grad
    allow_unused, accumulate_grad=False)  # Calls into the C++ engine to run the backward pass
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

How could I fix this? I haven't changed any line of code, and run everything as stated.

Generate animated SMPL model

test.py ran successfuly after around 11 hours, so I have the 42 canocial PLY meshes and 42 deformed PLY meshes in the outputs/Video/parkinglot/test_mesh.

Now I'd like to understand how I could obtain an SMPL animated model exported to an FBX format for example.

In #5 you mentioned how one could eventually obtain an animated SMPL model that could be imported into Blender for example. It seems you also gave some leads in #8

I saw a similar explanation in the Supplementary Material of Vid2Avatr at section "4. Animation". However I'm a bit confused here although I've not tried yet to read the related [15,19] papers.

Could you give me some hints to generate an animated SMPL model?
May I find relevant information in the others project of your team? Especially in the X-Avatar project?

Code release plan

Hi Chen,

Congrats on the amazing work! I am curious if you have any ETA on the first code release.

Best,
Hang

Pytorch3d import error on .so undefined symbol MemoryFormatEEE

Maybe it is a known issue, I am having trouble running python test.py

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from v2a_model import V2AModel
  File "/home/hangyu5/Documents/Git-repoMy/AIResearchVault/repo/AIGC/game changer/vid2avatar/code/v2a_model.py", line 3, in <module>
    from lib.model.v2a import V2A
  File "/home/hangyu5/Documents/Git-repoMy/AIResearchVault/repo/AIGC/game changer/vid2avatar/code/lib/model/v2a.py", line 4, in <module>
    from .deformer import SMPLDeformer
  File "/home/hangyu5/Documents/Git-repoMy/AIResearchVault/repo/AIGC/game changer/vid2avatar/code/lib/model/deformer.py", line 4, in <module>
    from pytorch3d import ops
  File "/home/hangyu5/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch3d/ops/__init__.py", line 7, in <module>
    from .ball_query import ball_query
  File "/home/hangyu5/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch3d/ops/ball_query.py", line 10, in <module>
    from pytorch3d import _C
ImportError: /home/hangyu5/anaconda3/envs/v2a/lib/python3.7/site-packages/pytorch3d/_C.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN2at5emptyEN3c108ArrayRefIlEENS0_13TensorOptionsENS0_8optionalINS0_12MemoryFormatEEE

However, I can import pytorch3d, but still fail at importing _C

Python 3.7.16 (default, Jan 17 2023, 22:20:44) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pytorch3d import _C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libc10.so: cannot open shared object file: No such file or directory
>>> import pytorch3d
>>> 

Here is my package version list pip list

Package                        Version            Editable project location
------------------------------ ------------------ -----------------------------------------------------------------------------------------
absl-py                        1.4.0
aiohttp                        3.8.4
aiosignal                      1.3.1
aitviewer                      1.10.0
antlr4-python3-runtime         4.8
async-timeout                  4.0.2
asynctest                      0.13.0
attrs                          23.1.0
cachetools                     5.3.1
certifi                        2022.12.7
charset-normalizer             3.1.0
chumpy                         0.70
click                          8.1.3
cycler                         0.11.0
Cython                         0.29.35
docker-pycreds                 0.4.0
Flask                          2.0.3
fonttools                      4.38.0
frozenlist                     1.3.3
fsspec                         2023.1.0
future                         0.18.3
fvcore                         0.1.5.post20221221
gitdb                          4.0.10
GitPython                      3.1.31
glcontext                      2.3.7
google-auth                    2.20.0
google-auth-oauthlib           0.4.6
grpcio                         1.56.0
hydra-core                     1.1.1
idna                           3.4
imageio                        2.31.1
imgui                          2.0.0
importlib-metadata             6.7.0
importlib-resources            5.12.0
iopath                         0.1.10
itsdangerous                   2.1.2
Jinja2                         3.1.2
joblib                         1.2.0
kaolin                         0.13.0
kiwisolver                     1.4.4
Markdown                       3.4.3
MarkupSafe                     2.1.3
matplotlib                     3.5.3
moderngl                       5.8.2
moderngl-window                2.4.4
multidict                      6.0.4
multipledispatch               0.6.0
networkx                       2.6.3
numpy                          1.21.6
oauthlib                       3.2.2
omegaconf                      2.1.2
opencv-contrib-python-headless 4.7.0.72
packaging                      23.1
pathtools                      0.1.2
Pillow                         9.5.0
pip                            22.3.1
portalocker                    2.7.0
promise                        2.3
protobuf                       3.20.3
psutil                         5.9.5
pyasn1                         0.5.0
pyasn1-modules                 0.3.0
pyDeprecate                    0.3.1
pyglet                         2.0.8
pyparsing                      3.1.0
PyQt5                          5.15.9
PyQt5-Qt5                      5.15.2
PyQt5-sip                      12.12.1
pyrr                           0.10.3
python-dateutil                2.8.2
pytorch-lightning              1.5.7
pytorch3d                      0.7.4
PyWavelets                     1.3.0
PyYAML                         6.0
requests                       2.31.0
requests-oauthlib              1.3.1
roma                           1.3.2
rsa                            4.9
scikit-image                   0.18.1
scikit-video                   1.1.11
scipy                          1.7.3
sentry-sdk                     1.26.0
setproctitle                   1.3.2
setuptools                     59.5.0
shortuuid                      1.0.11
six                            1.16.0
smmap                          5.0.0
smplx                          0.1.28
tabulate                       0.9.0
tensorboard                    2.11.2
tensorboard-data-server        0.6.1
tensorboard-plugin-wit         1.8.1
termcolor                      2.3.0
tifffile                       2021.11.2
torch                          1.13.1+cu117
torchmetrics                   0.11.4
torchvision                    0.10.1+cu111
tornado                        6.1
tqdm                           4.65.0
trimesh                        3.22.1
typing_extensions              4.6.3
UNKNOWN                        0.0.0              /home/hangyu5/Documents/Git-repoMy/AIResearchVault/repo/AIGC/game changer/vid2avatar/code
urllib3                        1.26.16
usd-core                       22.5.post1
wandb                          0.13.1
websockets                     11.0.3
Werkzeug                       2.2.3
wheel                          0.38.4
yacs                           0.1.8
yarl                           1.9.2
zipp                           3.15.0

About smpl_init.pth in assets

Thanks for sharing the code!

I found that smpl_init.pth in the asset folder is used for better convergence in the early training stage.
I want to change the MLP part of the implicit_network so I cannot use this initial checkpoint directly.

I thought this was the unit sphere initialization but it seems different because of the additional input, body pose.

What does smpl_init represent, and can you let me know the training pipeline to get smpl_init?

Thanks!

result mesh seems to be at the same place (NOT reaally an issue.)

From the test I did, seems like the result is standing on the same place, but the video created with the result seems to have the movement of the person from the video.

Is there a way that I could export that movement information? I supose it would be the SMPL coeficients, right ?

thanks a lot for all the help.

SynWild dataset inaccurate body poses

Hi, I was visualizing the body poses provided as 'ground truth' in the SynWild dataset, and came across some very noisy ones, for example:

Screenshot from 2023-09-19 09-58-33

However these poses are described as ground truth by the filename, which seems not to be the case. In the paper, you mention that the ground truth geometry is obtained from a dense MVS system on the dynamic 4D scene. So there shouldn't be any ground truth poses at all.

So I guess these poses were estimated with some other method, like ROMP. Is this correct?

Can you explain more about smpl transform?

Thank you for your amazing jobs!

I have a few questions from the preprocessing codes.

  • Can you explain more about below function?
  • Is there a reference world coordinate system?
  • Is this code translating the camera to a coordinate system based on smpl?
  • Why do you add hip?
  • Why do you do inverse?
  • What is "we assume" reference?
# transform SMPL such that the target camera extrinsic will be met
def transform_smpl(curr_extrinsic, target_extrinsic, smpl_pose, smpl_trans, T_hip):
    R_root = cv2.Rodrigues(smpl_pose[:3])[0]
    transf_global_ori = (
        np.linalg.inv(target_extrinsic[:3, :3]) @ curr_extrinsic[:3, :3] @ R_root
    )

    target_extrinsic[:3, -1] = (
        curr_extrinsic[:3, :3] @ (smpl_trans + T_hip)
        + curr_extrinsic[:3, -1]
        - smpl_trans
        - target_extrinsic[:3, :3] @ T_hip
    )

    smpl_pose[:3] = cv2.Rodrigues(transf_global_ori)[0].reshape(3)
    smpl_trans = np.linalg.inv(target_extrinsic[:3, :3]) @ smpl_trans  # we assume

    return target_extrinsic, smpl_pose, smpl_trans

Thank you once again.

Too long training time

I train on single NVIDIA RTX 3090 GPU. The data is only 270 frames, 1400 epochs run for five days. But github and the supplemental files say it only takes 48h, why is that? I see in the code that the maximum epoch of train is 8000. Is it necessary to run so many epochs.

Would it work on still images

Hi, I have possibly the most unsophisticated and silly question. Can this model create avatar form a single image as well? Apologies, if this was too silly for you to answer. but it's a genuine question. Thanks in advance.

About pre trained sdf field

Would you be able to provide the code for obtaining the pre-trained SDF field?
I've noticed that when I modify the SDF network without using the pre-trained field, the loss consistently diverges to NaN.

test.py not running

i trained the model with pytorch-lightning==1.9.5
showing this error when i run test.py

test.py:10: UserWarning: 
The version_base parameter is not specified.
Please specify a compatability version level, or None.
Will assume defaults for version 1.1
  @hydra.main(config_path="confs", config_name="base")
/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default.
See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information.
  ret = run_job(
Global seed set to 42
Working dir: /home/prityush/Desktop/avatar/vid2avatar/outputs/Video/parkinglot
/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:478: LightningDeprecationWarning: Setting `Trainer(gpus=1)` is deprecated in v1.7 and will be removed in v2.0. Please use `Trainer(accelerator='gpu', devices=1)` instead.
  rank_zero_deprecation(
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
checkpoints/last.ckpt
Restoring states from the checkpoint path at checkpoints/last.ckpt
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Loaded model weights from checkpoint at checkpoints/last.ckpt
Testing DataLoader 0:   0%|                                                                                                                                                                                | 0/42 [00:00<?, ?it/s]/home/prityush/Desktop/avatar/vid2avatar/code/v2a_model.py:217: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  num_splits = (total_pixels + pixel_per_batch -
/home/prityush/Desktop/avatar/vid2avatar/code/lib/utils/meshing.py:41: FutureWarning: marching_cubes_lewiner is deprecated in favor of marching_cubes. marching_cubes_lewiner will be removed in version 0.19
  verts, faces, normals, values = measure.marching_cubes_lewiner(
Error executing job with overrides: []
Traceback (most recent call last):
  File "test.py", line 43, in <module>
    main()
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "test.py", line 39, in main
    trainer.test(model, testset, ckpt_path=checkpoint)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 794, in test
    return call._call_and_handle_interrupt(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 842, in _test_impl
    results = self._run(model, ckpt_path=self.ckpt_path)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1112, in _run
    results = self._run_stage()
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1188, in _run_stage
    return self._run_evaluate()
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1228, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 152, in advance
    dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 137, in advance
    output = self._evaluation_step(**kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 234, in _evaluation_step
    output = self.trainer._call_strategy_hook(hook_name, *kwargs.values())
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1494, in _call_strategy_hook
    output = fn(*args, **kwargs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/pytorch_lightning/strategies/strategy.py", line 399, in test_step
    return self.model.test_step(*args, **kwargs)
  File "/home/prityush/Desktop/avatar/vid2avatar/code/v2a_model.py", line 268, in test_step
    model_outputs = self.model(batch_inputs)
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/prityush/Desktop/avatar/vid2avatar/code/lib/model/v2a.py", line 158, in forward
    fg_rgb_flat, others = self.get_rbg_value(points_flat, differentiable_points, view,
  File "/home/prityush/Desktop/avatar/vid2avatar/code/lib/model/v2a.py", line 237, in get_rbg_value
    _, gradients, feature_vectors = self.forward_gradient(x, pnts_c, cond, tfs, create_graph=is_training, retain_graph=is_training)
  File "/home/prityush/Desktop/avatar/vid2avatar/code/lib/model/v2a.py", line 258, in forward_gradient
    grad = torch.autograd.grad(
  File "/home/prityush/.pyenv/versions/vid_avatar/lib/python3.8/site-packages/torch/autograd/__init__.py", line 272, in grad
    return Variable._execution_engine.run_backward(
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
Testing DataLoader 0:   0%|          | 0/42 [00:07<?, ?it/s]                         

Code not working for multi-gpu setting

Sorry for the inconvenience, but this would be an awesome way to speed up training. I changed the line 22 of file code/train.py to be gpus=-1 which is the value for pytorch lightning to use all available gpus. But when doing so the following error appears:

RuntimeError: Cowardly refusing to serialize non-leaf tensor which requires_grad, since autograd does not support crossing process boundaries. If you just want to transfer the data, call detach() on the tensor before serializing (e.g., putting it on the queue).

The traceback points to the trainer.fit() line but it does not give any additional information pointing to any other file of your repository. If you could fix it and try on a multi-gpu setting this could make the project more usable. Thanks in advance.

How do you account for the human movement in background modeling?

It is assumed that the human is centered at the origin, while camera moves according to the human movement. Wouldn't the same 3d coordinate represent different locations in the background in different frames?
In other word, is it assumed that the background is always dynamic?

The same question as issue #11

Thank you!

pretrained shape network

Thank you for releasing the code! I see you mentioned in the supplementary materials that you did some pretraining on the shape network. Can you share this pretrained model? Also, would it still be able to learn the mask well if trained from scratch?

Can't reproduce results

When retraining from your pretrained checkpoint I start to get NaN in the in_shape_loss quite fast, after epoch 40 or so. I have repeated several times the process and always happens. When executing the testing code, not even a person shows up, it just a strange shape. Could you submit a way of perfectly reproducing your results without the need for training?

execute problem

Hi.
My GPU is nvidia 2070, installed torch 1.12.1 + cu11.3 +kaolin 0.13.0 / visual studio 2019
pip install torch==1.12.1 torchvision==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu113
image

All installations succeeded. but, training is fail.
I'm trying to run a training run, but I get the following error:
캡처1
image

I copied the preprocessed demo data to the following location
C:\cg\vid2avatar\data\parkinglot

Before starting the training, I also modified the path setting in metainfo.
캡처2
changed is_continue true.
image

What's the problem?

Implementation issue in gradient (surface normal) computation

Thanks for sharing the code.
I wonder whether this code is correct or not.

torch.einsum('bi,bij->bj', gradients, grads_inv)

which is located at

return grads.reshape(grads.shape[0], -1), torch.nn.functional.normalize(torch.einsum('bi,bij->bj', gradients, grads_inv), dim=1), feature


Let me describe my understanding.
The variable gradients indicates the surface normal vector at the canonical space,

gradients = torch.autograd.grad(
            outputs=sdf, # signed distance function
            inputs=pnts_c, # points at the canonical space
            grad_outputs=d_output,
            create_graph=create_graph,
            retain_graph=retain_graph,
            only_inputs=True,
)[0]

which is located at

gradients = torch.autograd.grad(

Accordingly, to compute the surface normal vector at the deformed space,
we need to use the Jacobian matrix (pnts_d over pnts_c) which is identical to the variable grads below,

grads = []
        for i in range(num_dim):
                d_out = torch.zeros_like(pnts_d, requires_grad=False, device=pnts_d.device)
                d_out[:, i] = 1
                grad = torch.autograd.grad(
                        outputs=pnts_d,
                        inputs=pnts_c,
                        grad_outputs=d_out,
                        create_graph=create_graph,
                        retain_graph=True if i < num_dim - 1 else retain_graph,
                        only_inputs=True,
                )[0]
                grads.append(grad)
grads = torch.stack(grads, dim=-2)
grads_inv = grads.inverse()

Based on these variables, I could compute the surface normal at the deformed space as

gradients_at_deformed_space = torch.bmm(grads, gradients.reshape(-1, 3, 1)).reshape(-1,3)

which is identical to the code below.

torch.einsum('bi,bij->bj', gradients, grads)

TL;DR) grads_inv -> grads

Can you check this issue? If I am wrong, please let me know.

Thanks.

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.