Coder Social home page Coder Social logo

hongwenzhang / danet-densepose2smpl Goto Github PK

View Code? Open in Web Editor NEW
218.0 9.0 35.0 767 KB

[TPAMI 2020] Learning 3D Human Shape and Pose from Dense Body Parts

Home Page: https://hongwenzhang.github.io/DensePose2SMPL

Python 97.82% Shell 0.04% Cython 2.14%
3d-human-shape-and-pose-estimation 3d-human-reconstruction smpl densepose-to-smpl human-mesh-recovery

danet-densepose2smpl's Introduction

Learning 3D Human Shape and Pose from Dense Body Parts

This repository contains the code for the following paper:

Learning 3D Human Shape and Pose from Dense Body Parts
Hongwen Zhang, Jie Cao, Guo Lu, Wanli Ouyang, Zhenan Sun

TPAMI, 2020

Project Page Project Page

Requirements

  • Python 3.6.10

packages

necessary files

DensePose UV data

  • Run the following script to fetch DensePose UV data.
bash get_densepose_uv.sh

SMPL model files

Fetch preprocessed data from SPIN and here.

Download the pre-trained models and put them into the ./data/pretrained_model directory.

After collecting the above necessary files, the directory structure of ./data is expected as follows.

./data
├── dataset_extras
│   └── .npz files
├── J_regressor_extra.npy
├── J_regressor_h36m.npy
├── pretrained_model
│   ├── .pt files
│   └── learned_ratio.pkl
├── smpl
│   ├── SMPL_FEMALE.pkl
│   ├── SMPL_MALE.pkl
│   └── SMPL_NEUTRAL.pkl
├── smpl_mean_params.npz
├── static_fits
│   └── .npy files
└── UV_data
    ├── UV_Processed.mat
    └── UV_symmetry_transforms.mat

Rendering IUV

The IUV_Renderer can be used to generate ground-truth IUV maps when given a batch of SMPL vertices and cameras. An example of usage can be found here.

Demo

  1. Run the demo code. Using --use_opendr if the opendr package is successfully installed.
python3 demo.py --checkpoint=data/pretrained_model/danet_model_h36m_itw.pt --img_dir ./examples --use_opendr
  1. View visualization results in ./output. Results are organized (from left to right) as the input image, the estimated IUV maps (global and partial), the rendered IUV of the predicted SMPL model, the predicted SMPL model (front and side views).

Evaluation

Human3.6M / 3DPW

Run the evaluation code. Using --dataset to specify the evaluation dataset.

# Example usage:

# Human3.6M Protocol 2
python3 eval.py --checkpoint=data/pretrained_model/danet_model_h36m_itw.pt --dataset=h36m-p2 --log_freq=20

# 3DPW
python3 eval.py --checkpoint=data/pretrained_model/danet_model_h36m_itw.pt --dataset=3dpw --log_freq=20

COCO Keypoint Localization

  1. Download the preprocessed data coco_2014_val.npz. Put it into the ./data/dataset_extras directory.

  2. Run the COCO evaluation code.

python3 eval_coco.py --checkpoint=data/pretrained_model/danet_model_h36m_dpcoco.pt

Training

To perform training, we need to collect pretraining models and preprocessed files of training datasets at first.

The pretraining models can be downloaded from HRNet. The preprocessed labels have the same format as SPIN and can be retrieved from here. Please refer to SPIN for more details about data preprocessing. As for DensePose-COCO, we provide the preprocessed data here.

The training of DaNet consists of two stages. We will train the IUV estimator alone at the first stage for around 5k iterations, then we involve other modules in training for the rest of 60k iterations at the second stage. Example usage:

python3 train.py --name danet --batch_size 16 --vis_interval 1000 --pretr_step 5000

Running the above command will use Human3.6M and DensePose-COCO for training by default. We can monitor the training process by setting up a TensorBoard at the directory ./logs.

Citation

If this work is helpful in your research, please cite the following paper.

@article{zhang2020densepose2smpl,
  title={Learning 3D Human Shape and Pose from Dense Body Parts},
  author={Zhang, Hongwen and Cao, Jie and Lu, Guo and Ouyang, Wanli and Sun, Zhenan},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
  volume={44},
  number={5},
  pages={2610--2627},
  year={2022},
}

Acknowledgments

The code is developed upon the following projects. Many thanks to their contributions.

danet-densepose2smpl's People

Contributors

hongwenzhang avatar tinatiansjz 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

danet-densepose2smpl's Issues

Some files cannot be found

Thanks for your excellent work!
I meet an error about some files when running your demo.py.
J_regressor_extra.npy, J_regressor_h36m.npy and smpl_mean_params.npy cannot be found.
I would like to know where I can get these files.
Thanks again!

how to obtain the h36m_mosh_train.npz

Hi!
I would like to retrain this code with the human3.6 dataset. However, I meet an error which h36m_mosh_train.npz can not be found.
Where can I get this file?
thanks!

Running on different size images?

Hi, thanks for your paper and code. I'm trying to make it run on bigger images, kind of struggling with it. Do you think it will be easy or needs major code and model changes? Thanks

Error of smplx

Hi, thanks for your released codes. When I running the demo.py, it cames some errors:

File "/ssd1/vis/lintianwei/3d/DaNet-3DHumanReconstruction-master/models/smpl.py", line 7, in
from smplx.body_models import ModelOutput
ImportError: cannot import name 'ModelOutput'

Do you know how to fix this?

Questions about uv map

Hi, thank you for you awesome work! I am a beginner of computer vision and computer graphics, and I have some confusion about uv map.
1: How to construct the template texture map when you prepare IUV maps?
If I understand correctly, in the texture map of fig2, the horizontal and vertical axis are uv coordiantes, and the value in the pixel is the SMPL vertex coordinate corresponding to uv, so how to construct the texture map? And why the layout of body parts in this texture map is different from the layout of texture map in Densepose paper?Is there an explicit correspondence between uv coordinates and vertex coordinates?Like u,v=f(x,y,z)

Issue with dimmensions

Hi
I am working on your model and having issue while running the code as i have all dependencies issue but still i cannot figure out the issue.

I have tried with both the SMPL models like version 1.1.0 and 1.0.0 but it still having dimensions issue

can you please help me in figuring out the issue

ERROR:

using decomposed predictor.
input mode: IUV
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:2693: UserWarning: Default grid_sample and affine_grid behavior will be changed to align_corners=False from 1.4.0. See the documentation of grid_sample for details.
warnings.warn("Default grid_sample and affine_grid behavior will be changed "
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:2751: UserWarning: Default grid_sample and affine_grid behavior will be changed to align_corners=False from 1.4.0. See the documentation of grid_sample for details.
warnings.warn("Default grid_sample and affine_grid behavior will be changed "
Traceback (most recent call last):
File "demo.py", line 184, in
main()
File "demo.py", line 149, in main
global_orient=rotmat_pred[:, 0].unsqueeze(1), pose2rot=False)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/content/drive/My Drive/Ayush_Gupta/3d_cloth/DaNet-3DHumanReconstruction/models/smpl.py", line 29, in forward
smpl_output = super(SMPL, self).forward(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/smplx/body_models.py", line 376, in forward
self.lbs_weights, pose2rot=pose2rot, dtype=self.dtype)
File "/usr/local/lib/python3.7/dist-packages/smplx/lbs.py", line 179, in lbs
v_shaped = v_template + blend_shapes(betas, shapedirs)
File "/usr/local/lib/python3.7/dist-packages/smplx/lbs.py", line 265, in blend_shapes
blend_shape = torch.einsum('bl,mkl->bmk', [betas, shape_disps])
File "/usr/local/lib/python3.7/dist-packages/torch/functional.py", line 201, in einsum
return torch._C._VariableFunctions.einsum(equation, operands)
RuntimeError: size of dimension does not match previous size, operand 1, dim 2

RuntimeError: faces must be contiguous?

Hi, thanks for your code. But when I run python demo.py --checkpoint=data/pretrained_model/danet_model_h36m_itw.pt --img_dir ./examples --use_opendr, this error was reported.

/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/torch/nn/functional.py:4004: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
"Default grid_sample and affine_grid behavior has changed "
/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/torch/nn/functional.py:4066: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
"Default grid_sample and affine_grid behavior has changed "
Traceback (most recent call last):
File "demo.py", line 184, in
main()
File "demo.py", line 151, in main
render_iuv = iuv_renderer.verts2uvimg(verts_pred, camera_pred)
File "/mnt/d/Study/DaNet-3DHumanReconstruction/utils/renderer.py", line 276, in verts2uvimg
dist_coeffs=torch.FloatTensor([[0.] * 5]).to(verts.device))
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/renderer.py", line 74, in forward
return self.render_rgb(vertices, faces, textures, K, R, t, dist_coeffs, orig_size)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/renderer.py", line 197, in render_rgb
self.background_color)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/rasterize.py", line 394, in rasterize
faces, textures, image_size, anti_aliasing, near, far, eps, background_color, True, False, False)['rgb']
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/rasterize.py", line 303, in rasterize_rgbad
image_size, near, far, eps, background_color, return_rgb, return_alpha, return_depth)(*inputs)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/rasterize.py", line 251, in forward
self.return_rgb, self.return_alpha, self.return_depth)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/rasterize.py", line 74, in forward
face_inv_map)
File "/home/pisceskkk/miniconda3/envs/danet/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg/neural_renderer/rasterize.py", line 166, in forward_face_index_map
ctx.return_depth)
RuntimeError: faces must be contiguous

And my env:
Ubuntu20 in WSL2
python 3.6.13
torch 1.10.0+cu113
neural-renderer-pytorch 1.1.3
opendr 0.78

Question about female/neutral model

Really a great work!
I have some issue if I try to use a model different from SMPL male model. If I place female or neutral model, the reconstruction doesn't match with original image. I attach the example of a female pic with different result
here the image:
testwomanresize

Here with male model (good):
testwomanresize_result_malemodel

here with female model:
testwomanresize_result_femalemodel

here with neutral model:
testwomanresize_result_neutralmodel

Is it only an issue of visualization of the model shall be trained with different models?

Thanks,

Error running demo.py

Hi! I tried to run demo.py, however an error occurred as follows:

Traceback (most recent call last):
  File "demo.py", line 184, in <module>
    main()
  File "demo.py", line 149, in main
    global_orient=rotmat_pred[:, 0].unsqueeze(1), pose2rot=False)
  File "/home/yujun/anaconda3/envs/danet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/yujun/ludai/DaNet-3DHumanReconstruction/models/smpl.py", line 29, in forward
    smpl_output = super(SMPL, self).forward(*args, **kwargs)
  File "/home/yujun/anaconda3/envs/danet/lib/python3.6/site-packages/smplx/body_models.py", line 376, in forward
    self.lbs_weights, pose2rot=pose2rot, dtype=self.dtype)
  File "/home/yujun/anaconda3/envs/danet/lib/python3.6/site-packages/smplx/lbs.py", line 179, in lbs
    v_shaped = v_template + blend_shapes(betas, shapedirs)
  File "/home/yujun/anaconda3/envs/danet/lib/python3.6/site-packages/smplx/lbs.py", line 269, in blend_shapes
    blend_shape = torch.einsum('bl,mkl->bmk', [betas, shape_disps])
  File "/home/yujun/anaconda3/envs/danet/lib/python3.6/site-packages/torch/functional.py", line 211, in einsum
    return torch._C._VariableFunctions.einsum(equation, operands)
RuntimeError: size of dimension does not match previous size, operand 1, dim 2

Can you give me any help regarding this issue? 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.