THuman2.0-Dataset icon indicating copy to clipboard operation
THuman2.0-Dataset copied to clipboard

smplx_param.pkl are unaligned with mesh_smplx.obj

Open TingtingLiao opened this issue 2 years ago • 8 comments

The smplx mesh generated by smplx_param.pkl is unaligned with mesh_smplx.obj. Here is the code:

param = np.load(param_path, allow_pickle=True)
param = {k: torch.as_tensor(v) for k, v in param.items()}
smpl_out = self.smpl_model(shape_params=param['betas'],
                                   expression_params=param['expression'],
                                   body_pose=param['body_pose'],
                                   global_pose=param['global_orient'],
                                   jaw_pose=param['jaw_pose'],
                                   left_hand_pose=param['left_hand_pose'],
                                   right_hand_pose=param['right_hand_pose'],
                                   leye_pose=param['leye_pose'],
                                   reye_pose=param['reye_pose'])

smpl_verts = (smpl_out.vertices[0] * param['scale'] + param['translation'].view(1, 3)).detach().cpu().numpy()

and the generated results of ID 0000 with released smplx mesh: image

TingtingLiao avatar May 09 '22 07:05 TingtingLiao

Hi Tingting,

Do you use the officially released SMPL-X model for generating the mesh?

ytrock avatar May 10 '22 04:05 ytrock

Hi Tingting,

Do you use the officially released SMPL-X model for generating the mesh?

Yes, I download it from the official link.

TingtingLiao avatar May 10 '22 05:05 TingtingLiao

@Tessantess, please check here, I corrected some bugs and for now the rendering works well.

YuliangXiu avatar May 14 '22 19:05 YuliangXiu

@ytrock Similar problem (not such big as the tingting's, only slight difference). BTW: how to translate the hand_pose (12 dim in your offered params) to the default one (15*3 in SMPLX default).

wangsen1312 avatar May 15 '22 04:05 wangsen1312

@wangsen1312 , the provided 12 dim parameters is the PCA parameters of the hand pose, so please use the corresponding interface for generating the mesh.

ytrock avatar May 15 '22 12:05 ytrock

Thank you! Everything goes perfect now. @ytrock

wangsen1312 avatar May 16 '22 15:05 wangsen1312

Hi Tingting,

Do you use the officially released SMPL-X model for generating the mesh?

The results gets right after using specific gender parameters. Could you please release the corresponding gender list of all subjects?

TingtingLiao avatar May 17 '22 08:05 TingtingLiao

@Tessantess It works right for me with 'Male' gender for all people. I get meshes with this code:

import os
import smplx
import trimesh
import pickle
import torch
from glob import glob
import numpy as np


model_init_params = dict(
    gender='male',
    model_type='smplx',
    model_path='/home/david/Samsung',
    create_global_orient=False,
    create_body_pose=False,
    create_betas=False,
    create_left_hand_pose=False,
    create_right_hand_pose=False,
    create_expression=False,
    create_jaw_pose=False,
    create_leye_pose=False,
    create_reye_pose=False,
    create_transl=False,
    num_pca_comps=12) 

smpl_model = smplx.create(**model_init_params)

pickle_folder = '/home/david/Datasets/THuman2.0/THUman2.0__Smpl-X/'
pickle_files = glob(os.path.join(pickle_folder, '*/*.pkl'))

for pickle_filename in pickle_files:
    
    param = np.load(pickle_filename, allow_pickle=True)
    for key in param.keys():
        param[key] = torch.as_tensor(param[key]).to(torch.float32)

    model_forward_params = dict(betas=param['betas'],
                                global_orient=param['global_orient'],
                                body_pose=param['body_pose'],
                                left_hand_pose=param['left_hand_pose'],
                                right_hand_pose=param['right_hand_pose'],
                                jaw_pose=param['jaw_pose'],
                                leye_pose=param['leye_pose'],
                                reye_pose=param['reye_pose'],
                                expression=param['expression'],
                                return_verts=True)

    smpl_out = smpl_model(**model_forward_params)

    smpl_verts = (
        (smpl_out.vertices[0] * param['scale'] + param['translation'])).detach()
    smpl_mesh = trimesh.Trimesh(smpl_verts,
                                smpl_model.faces,
                                process=False, 
                                maintain_order=True)
    
    mesh_fname = pickle_filename.replace('.pkl', '_myvis.obj')
    smpl_mesh.export(mesh_fname)

david-svitov avatar Jun 14 '22 14:06 david-svitov