ytrock / THuman2.0-Dataset

290 stars 8 forks source link

smplx_param.pkl are unaligned with mesh_smplx.obj #9

Open TingtingLiao opened 2 years ago

TingtingLiao commented 2 years ago

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

ytrock commented 2 years ago

Hi Tingting,

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

TingtingLiao commented 2 years ago

Hi Tingting,

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

Yes, I download it from the official link.

YuliangXiu commented 2 years ago

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

wangsen1312 commented 2 years ago

@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).

ytrock commented 2 years ago

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

wangsen1312 commented 2 years ago

Thank you! Everything goes perfect now. @ytrock

TingtingLiao commented 2 years ago

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?

david-svitov commented 2 years ago

@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)