ytrock / THuman2.0-Dataset

292 stars 8 forks source link

mesh_smplx.obj is not aligned with smplx_param.pkl on THuman2.1 dataset #22

Open TiantianWang opened 3 months ago

TiantianWang commented 3 months ago

Dear all,

I have extracted the smplx mesh ('mesh_smplx_myself.obj') from the smplx_param.pkl. However it seems that the mesh extracted by myself is not aligned with the given mesh_smplx.obj. Please see the visualization and code below on 0527. Could you give some insight about how to extract the same mesh as mesh_smplx.obj from .pkl ?

Thanks

fig1 fig2

model_init_params = dict(
    gender='male',
    model_type='smplx',
    model_path=SMPLX().model_dir,
    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=45, # 45 or 12
)

smpl_model = smplx.create(**model_init_params)

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'],
    transl=param['transl'],
    return_verts=True
)
smpl_out = smpl_model(**model_forward_params)
smpl_verts = ((smpl_out.vertices[0] * param['scale']) * scale).detach()
smpl_joints = ((smpl_out.joints[0] * param['scale']) * scale).detach()
rescale_fitted_body = trimesh.Trimesh(smpl_verts, smpl_model.faces, process=False, maintain_order=True)
scale = 100
smplx_file = 'mesh_smplx_myself.obj'
trimesh.Trimesh(rescale_fitted_body.vertices / scale,
                rescale_fitted_body.faces).export(smplx_file)
ytrock commented 3 months ago

working on it...

zhanghebuaa commented 3 months ago

We have noticed the issue of inconsistent parameter representations between the two batches of data before and after 526, and are working on it. Currently, you can try: gender='neutral', use_pca=False. The following code will solve your problem:

params = np.load('THuman2.1/smplx/0527/smplx_param.pkl', allow_pickle=True) m_smplx = smplx.SMPLX('bodyModels/smplx', gender='neutral', use_pca=False) smpl_out = m_smplx.forward( transl=torch.tensor(params['transl']), global_orient=torch.tensor(params['global_orient']), body_pose=torch.tensor(params['body_pose']), betas=torch.tensor(params['betas']), left_hand_pose=torch.tensor(params['left_hand_pose']), right_hand_pose=torch.tensor(params['right_hand_pose']), expression=torch.tensor(params['expression']), jaw_pose=torch.tensor(params['jaw_pose']), leye_pose=torch.tensor(params['leye_pose']), reye_pose=torch.tensor(params['reye_pose']) ) vertices = smpl_out.vertices.detach().cpu().numpy()[0] * params['scale'] m_model = trimesh.Trimesh(vertices=vertices, faces=m_smplx.faces, process=False) m_model.export('debug/smplx_0527.obj')