Giter Site home page Giter Site logo

decomr's Introduction

DecoMR

Code repository for the paper:
3D Human Mesh Regression with Dense Correspondence
[Wang Zeng, Wanli Ouyang, Ping Luo, Wentao Liu, Xiaogang Wang]
CVPR 2020
[paper]

teaser.

Installation instructions

This project is tested on ubuntu 16.04 with python 3.6, PyTorch 1.1. We recomend using Anaconda to create a new enviroment:

conda create -n DecoMR python=3.6
conda activate DecoMR

Install dependecies: This project utilizes OpenDR to render 3D mesh. In order to install OpenDR on Python 3.6, libosmesa6-dev needs to be installed first:

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
sudo apt-get install libosmesa6-dev
sudo apt-get install gfortran
pip install --force-reinstall pip==19
pip install -r requirements.txt

After finishing with the installation, you can continue with running the demo/evaluation/training code. If you want to do the evaluation on Human3.6M, you also need to manually install the pycdf package of the spacepy library to process some of the original files. If you face difficulties with the installation, you can find more elaborate instructions here.

Fetch data

In order to run our code, you need to download some additional file here. This package contains neccessary files for UV mapping function and a model trained on Human3.6M + UP-3D. After unzip the files, you need to put the folder under this project.

In addition, you need to fetch the neutral SMPL model from the Unite the People repository:

wget https://github.com/classner/up/raw/master/models/3D/basicModel_neutral_lbs_10_207_0_v1.0.0.pkl --directory-prefix=data

The model falls under the SMPLify license. If you find this model useful for your research, please follow the corresponding citing insturctions.

In order to perform the evaluation on 3DPW or SURREAL dataset, you also need to get the male and female models. Please go to the websites for the corresponding projects and register to get access to the downloads section.

Run demo code

To run our method, you need a bounding box around the person. The person needs to be centered inside the bounding box and the bounding box should be relatively tight. You can either supply the bounding box directly or provide an OpenPose detection file. In the latter case we infer the bounding box from the detections.

In summary, we provide 3 different ways to use our demo code and models:

  1. Provide only an input image (using --img), in which case it is assumed that it is already cropped with the person centered in the image.
  2. Provide an input image as before, together with the OpenPose detection .json (using --openpose). Our code will use the detections to compute the bounding box and crop the image.
  3. Provide an image and a bounding box (using --bbox). The expected format for the json file can be seen in examples/im1010_bbox.json.

Example with OpenPose detection .json

python demo.py --checkpoint=data/model/h36m_up3d/checkpoints/h36m_up3d.pt --config=data/model/h36m_up3d/config.json --img=examples/im1010.jpg --openpose=examples/im1010_openpose.json

Example with predefined Bounding Box

python demo.py --checkpoint=data/model/h36m_up3d/checkpoints/h36m_up3d.pt --config=data/model/h36m_up3d/config.json --img=examples/im1010.jpg --bbox=examples/im1010_bbox.json

Example with cropped and centered image

python demo.py --checkpoint=data/model/h36m_up3d/checkpoints/h36m_up3d.pt --config=data/model/h36m_up3d/config.json --img=examples/im1010.jpg

Running the previous command will save the results in examples/im1010_{render, render_side}.png. The file im1010_render.png shows the overlayed reconstructions of the non-parametric shapes. The file im1010_render_side.png shows the mesh in the side view.

Run evaluation code

We provide code to evaluate our models on the datasets we employ for our empirical evaluation. Before continuing, please make sure that you follow the details for data preprocessing.

Example usage:

python eval.py --checkpoint=data/model/h36m_up3d/checkpoints/h36m_up3d.pt  --dataset=h36m-p1 --log_freq=20

Running the above command will compute the MPJPE and MPJPE-PA on the Human3.6M dataset (Protocol I). The --dataset option can take different values based on the type of evaluation you want to perform:

  1. Human3.6M Protocol 1 --dataset=h36m-p1
  2. Human3.6M Protocol 2 --dataset=h36m-p2
  3. UP-3D --dataset=up-3d
  4. LSP --dataset=lsp
  5. 3DPW --dataset=3dpw
  6. MPI-INF-3DHP --dataset=mpi-inf-3dhp
  7. SURREAL --dataset=surreal

Run training code

Due to license limitiations, we cannot provide the SMPL parameters for Human3.6M (recovered using MoSh). So you may need to get the training data of Human3.6M by yourself.

The training process is two-stage. In the first stage, the correspondence net is trained. Example usage:

python train.py --name=sample_dp --stage=dp --num_epoch=5

Running the above command will start the training process of the Correspondence Net. It will also create the folders logs/sample_dp that is used to save model checkpoints and Tensorboard logs. If you start a Tensborboard instance pointing at the directory logs/sample_dp/tensorboard, you should be able to look at the logs stored during training.

In the second stage, the pretrained Correspondence Net is loaded and trained with the Location Net end-to-end. Example usage:

python train.py --name=sample_end --stage=end --pretrained_checkpoint=logs/sample_dp/checkpoints/final.pt

Running the above command will start the training process of the full model. It will create the folders logs/sample_end to save model checkpoints and Tensorboard logs.

The default training pararmeters use 8 gpus and the default batch size is 128. You can change the setting by resetting --ngpu and --batch_size. You can view the full list of command line options by running python train.py --help. The default values are the ones used to train the models in the paper.

Latest Update

2020.09.01

We recently added the training and evaluation code on several datasets: SURREAL, 3DPW and MPI-INF-3DHP. You can get the preprocess details from here.

We add the training code to use the SPIN fits as supervision and provide the pretrained models.

2020.09.24

We fixed the bug of the gender label in SURREAL dataset, and retrained the model on SURREAL dataset.

If you are using the codes updated on 2020.09.01, you need to delete the annotation files of SURREAL dataset (surreal_train.npz and surreal_val.npz) and then run preprocess_extra_datasets.py again to get the right gender labels.

Fortunately, you do NOT need to remove the rendered IUV images of SURREAL dataset, because the rendered IUV images are with right gender labels. So the preprocess won't take too much time.

Citing

If you find this code useful for your research, please consider citing the following paper:

@Inproceedings{zeng20203d,
  Title={3D Human Mesh Regression with Dense Correspondence},
  Author={Zeng, Wang and Ouyang, Wanli and Luo, Ping and Liu, Wentao and Wang, Xiaogang},
  Booktitle={CVPR},
  Year={2020}
}

Acknowledgements

Part of the code and data are adapted from (Graph-CMR, DenseBody, SPIN) . We gratefully appreciate the impact they had on our work.

We also appreciate wangzheallen for making the installation easier.

decomr's People

Contributors

wangzheallen avatar zengwang430521 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

decomr's Issues

AttributeError: 'ColoredRenderer' object has no attribute 'vbo_verts_face'

Traceback (most recent call last):
  File "demo.py", line 140, in <module>
    img=img, use_bg=True, body_color='pink')
  File "/data/DecoMR/utils/renderer.py", line 351, in render
    return self.renderer.r
  File "/home/xumingkai/.local/lib/python3.6/site-packages/chumpy/ch.py", line 555, in r
    self._call_on_changed()
  File "/home/xumingkai/.local/lib/python3.6/site-packages/chumpy/ch.py", line 550, in _call_on_changed
    self.on_changed(self._dirty_vars)
  File "/home/xumingkai/.local/lib/python3.6/site-packages/opendr/renderer.py", line 1080, in on_changed
    self.vbo_verts_face.set_array(np.array(self.verts_by_face).astype(np.float32))
AttributeError: 'ColoredRenderer' object has no attribute 'vbo_verts_face'

Some questions about SMPL parameter of Human36m

1、if i use the SMPL parameter generated by SMPLify-X. Should i use the 'trans' matrix genereted by SMPLify-X of SMPL to get the 'sampled_vertices' , or could i use SMPL(pose, betas, trans) to get the 'sampled_vertices' ?
2、And how do we get the camera coordinates from joints calaculated from 'sampled_vertices' generated by SMPL(). use 'self.smpl.get_train_joints(sampled_vertices)' ? but it never use 'J_regressor_h36m.npy'

I've just been in touch with this research direction, and I'm looking forward to your reply. Thank you

what is the meaning of tv_loss?

definition of tv_loss:

def tv_loss(self, uv_map):

it is with weight 0.0001 when training on up-3d.
I am not sure about the meaning of the loss.

Will this loss only apply only at uv_res 128 or less? If I have a uv_res at 256, does that mean we can get rid of the loss?

Missing file 'up_3d_trainval.npz'

Missing file 'up_3d_trainval.npz' when I run
'python preprocess_datasets.py --gt_iuv'

I do not see the 'Bboxes' in original H36M website, can you also provide the 'Bboxes'

Data pre-processing about generating UV map

May I ask what is the physical meaning behind line 45-46, is that orthographic projection? or transformation to UV space?
https://github.com/zengwang430521/DecoMR/blob/master/datasets/preprocess/generate_gt_iuv.py#L45

and
https://github.com/zengwang430521/DecoMR/blob/master/datasets/preprocess/generate_gt_iuv.py#L52
why do you have '1 - uv_tmp[:, :, 0]'

Additionally, I agree it is continuous among different semantic body parts in your UV map, which makes the learning easier.
Is the frontal view and back view of the same finger continuous in your defined UV map? as in Fig 3 in original paper.

A potential problem of warp_feature

Hi @zengwang430521 ,
I noticed that in your implementation of the warp_feature, a single element in the output transferred F_{uv} could potentially correspond to multiple elements in the local feature F_{im}.
For example, the u,v coordinate of a element in F_{uv} is [16,16]. While in the IUV image, the u,v coordinates are of float type. Then, rounding is required to create the correspondence, and thus multiple locations in the IUV image (e.g., an element with [u,v] = [16.1, 16.6] and another element with [u,v] = [16.4, 16.7]). Then two locations in F_{im} correspond to the single location in the F_{uv}.

Therefore, I am wondering which feature vectors will be transferred?

Best.

ImportError: /home/ni/anaconda3/lib/python3.7/site-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E

when i run the eval.py on the lsp_test dataset.

`/home/ni/anaconda3/bin/python /home/ni/DecoMR/eval.py --checkpoint=data/model/h36m_up3d/checkpoints/h36m_up3d.pt --dataset=lsp --log_freq=20
Checkpoint loaded
data loader finish
Traceback (most recent call last):
File "/home/ni/DecoMR/eval.py", line 318, in
run_evaluation(model, args, options, args.dataset, args.log_freq)
File "/home/ni/DecoMR/eval.py", line 122, in run_evaluation
from utils.part_utils import PartRenderer
File "/home/ni/DecoMR/utils/part_utils.py", line 7, in
import neural_renderer as nr
File "/home/ni/anaconda3/lib/python3.7/site-packages/neural_renderer/init.py", line 3, in
from .load_obj import load_obj
File "/home/ni/anaconda3/lib/python3.7/site-packages/neural_renderer/load_obj.py", line 8, in
import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /home/ni/anaconda3/lib/python3.7/site-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E

Process finished with exit code 1`

Do you know the cause of this problem

License?

Hi Zeng Wang,

Thanks for this great work! What is the license for this repository? If you could add it, that would be greatly appreciated. Thanks in advance.

FYI - here's what happens if a repository has no license:
"You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work."

Best,
Saafke

help of predict about camera parameter?

hello,i find we predict the camera parameter[z,tx,ty],and then we get the wold coordinate[tx,ty,2×focal_length/img_size×z],and we get this picture just use the world coordinate in render,
image
now,i want to use pytorch3d to replace the original renderer,but in pytorch3d,the setting in camera should know the R and T,but we only konw the world coordinate [tx,ty,2×focal_length/img_size×z],can you help me,how can i use pytorch3d to get the same img(There can be no background image)

How to reconstruct mesh based on the vertex location

May I ask how do you reconstruct SMPL parameters given the vertex location (location map) from your work?
And what is the shape of the location map? (is that a 3 channel xyz denoting the camera coordinate in mm?)

Camera coordinate joint prediction?

May I ask is the pred_vertices in camera coordinate?

DecoMR/demo.py

Line 134 in 726c7a1

pred_vertices = pred_vertices[0].cpu().numpy()

and will the following operations make it in root-relative coordinate and in mm unit? so that we can use the pred_keypoints_3d to calculate MPJPE with the ground truth in root-relative coordinate?

pred_keypoints_3d = smpl.get_train_joints(pred_vertices)[:, joint_mapper]
pred_pelvis = (pred_keypoints_3d[:, [2]] + pred_keypoints_3d[:, [3]]) / 2
pred_keypoints_3d = pred_keypoints_3d - pred_pelvis

dp_loss weight meaning?

May I ask what is the meaning of the weight in line 276-280
in https://github.com/zengwang430521/DecoMR/blob/master/train/base_trainer.py#L276?

Is this weighting on whether the u channel should penalize more or v channel should penalize more?
or
it is each pixel and channel weight for activation larger than 0?

Will this weight make overall loss smaller?

and why the UV head needs Sigmoid? only to normalize the activation to 0~1? will this stabilize training and make it converge faster?

nn.Sigmoid())

Thanks!

Why do you assume that all target meshes are female in SURREAL?

I run your evaluation code on SURREAL test set (493 imgs), and found out that the dataloader code only provides female genders.
Why don't you use the groundtruth genders which are provided in the dataset for the correct evaluation?

When I test your pre-trained model on SURREAL test set with groundtruth genders, I get
MPJPE: 67.82
MPVPE (Surface error): 64.59

These numbers are far different from the numbers reported in the paper (MPVPE: 56.5 , Tab.3) and not much good compared to the accuracy of BodyNet (MPVPE (Surface error): 65.8).

When I test your pre-trained model on SURREAL test set with intact code, I get
MPJPE: 54.29
MPVPE (Surface error): 51.65

Do you have any idea to get the numbers you reported in the paper?
And I think assuming all target meshes as female is inappropriate and unfair to compare to BodyNet results.

Want to get the Human3.6m IUV Map

Hi,
Thanks the great work! You propose the Boundary Free IUV Map to replace the DensePose IUV Map. I agree you said the BF IUV Map is more continuous than the DensePose IUV. So I want to use BF IUV Map. But you only provide the 56x56 pred_IUV Map, It is not accurate for me. I want to tranining the generating BF IUV Map model to satisfy my needed. Could you provide the BF IUV Map Datasets?

Thanks very much!

Theory behind ' Ensure the neighboring pixels of vt on the UV map are meaningful'

Hi Wang,
I am trying to understand the bary-weight calculation process.
Basically you are trying to mapping the uv space faces to xyz space faces and want to solve the weight between them.
However, I start to get lost from https://github.com/zengwang430521/DecoMR/blob/master/models/uv_generator.py#L179
and fail to understand why and what is the theory/intuition behind that about
the calculation of w, u, v?

I know from https://github.com/zengwang430521/DecoMR/blob/master/models/uv_generator.py#L205 you are trying to construct a mask in UV space, but the lines before that seems confusing to me.

something wrong with resampling uv map

Given smpl shape and pose parameters, I used get_UV_map(verts) and directly resampled the UV map generated from that function. The result is like this:
image
image
I have tried 'SMPL' and 'BF'. How to fix this problem and obtain a smooth mesh?

Question about the coordinate system of location map

Hi, thanks for your great work!

I have a question about the location map. Specifically, I want to know which is the coordinate system w.r.t. the 3 channel(xyz) of the pixel in the location map. It seems be defined in the camera coordinate rather than the world coordinate, am I right? If so, can you tell me why not use the world coordinate?

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.