ICON icon indicating copy to clipboard operation
ICON copied to clipboard

How to generate the aligned SMPL(not SMPL-X) fits of the Thuman2 scans?

Open lyk412 opened this issue 2 years ago • 3 comments

Hi, sorry to bother you again. I want to generate the aligned fits of the Thuman2 scans, but I encountered unexpected problems when I deal with the SMPL(not SMPL-X) fits.

Specifically, as for SMPL-X fits, I run the code as follow,

smplx_fit_file = os.path.join(data_root + "/fits", f'{subject}/smplx_param.pkl')
rescale_fitted_body, joints = load_fit_body(smplx_fit_file,
                                            1,
                                            smpl_type='smplx',
                                            smpl_gender='male')
rescale_fitted_body.export(data_root +f'/smplx_{subject}.obj')

and got the well aligned SMPL-X fits of the scan, shown as follow, image

As for SMPL fits generation, I run the following code consistent with the idea of the funtion load_fit_body

# load fit smpl body
param = np.load(smpl_fit_file, allow_pickle=True)
for key in param.keys():
    param[key] = torch.as_tensor(param[key])

smpl_model = get_smpl_model(smpl_type, gender='male')
model_forward_params = dict(betas=param['betas'],
                            body_pose=param['body_pose'],
                            global_orient=param['global_orient'],
                            transl=param['transl'],
                            return_verts=True)

smpl_out = smpl_model(**model_forward_params)

smpl_verts = (
    (smpl_out.vertices[0] * param['scale'] + param['transl']) *
    1).detach()
smpl_joints = (
    (smpl_out.joints[0] * param['scale'] + param['transl']) *
    1).detach()
smpl_mesh = trimesh.Trimesh(smpl_verts,
                            smpl_model.faces,
                            process=False,
                            maintain_order=True)
smpl_mesh.export(data_root + f"/smpl_{subject}.obj")

But I got the SMPL fit that is not aligned with the scan shown as follow, image image

I have tried a few days but got no ideas, could you give me some advice? Thanks very much!

lyk412 avatar Jan 19 '23 06:01 lyk412

You could check load_smpl_voxel to see how to load smpl.pkl correctly.

Especially this part:

verts = (
                np.concatenate([smpl_model.verts, smpl_model.verts_added], axis=0) *
                smpl_param["scale"] + smpl_param["translation"]
            ) * self.datasets_dict[data_dict["dataset"]]["scale"]

YuliangXiu avatar Jan 21 '23 02:01 YuliangXiu

I fing in some objects, the smpl-x is aligned with scan, such 0000: image but in some objects, the smpl-x is not aligned with scan, such 0029: image

could you give me some advice? thank you! @YuliangXiu @lyk412

gushengbo avatar Feb 10 '23 08:02 gushengbo

I fing in some objects, the smpl-x is aligned with scan, such 0000: image but in some objects, the smpl-x is not aligned with scan, such 0029: image

could you give me some advice? thank you! @YuliangXiu @lyk412

Maybe this comes from the original false SMPL-X fits, you can re-fit SMPL-X for these scans and replace the wrong fits.

YuliangXiu avatar May 04 '23 09:05 YuliangXiu