vchoutas / smplx

SMPL-X
https://smpl-x.is.tue.mpg.de/
Other
1.85k stars 308 forks source link

Convert SMPL-H to SMPL-X #82

Closed Jiankai-Sun closed 3 years ago

Jiankai-Sun commented 3 years ago

Hi, thanks for the code! I tried to convert an SMPL-H model (.obj generated by the following code piece) to an SMPL-X representation. While trying to run this code python -m transfer_model --exp-cfg config_files/smplh2smplx.yaml, I met several problems.

save_folder = '/'.join(sample_paths[seq_no].split('/')[3:-1]) obj_name = sample_paths[seq_no].split('/')[-1] for i in range(all_step_vertices.shape[0]): if args.model_type in ['smpl', 'smplh']: mesh = trimesh.Trimesh(vertices=c2c(all_step_vertices[i]), faces=faces, vertex_colors=np.tile(colors['grey'], (6890, 1))) else: mesh = trimesh.Trimesh(vertices=c2c(all_step_vertices[i]), faces=faces, vertex_colors=np.tile(colors['grey'], (10475, 1))) os.makedirs(osp.join(OUTPUT_DIR, save_folder), exist_ok=True) save_dir = osp.join(OUTPUT_DIR, savefolder, '{0}{1:02d}.obj'.format(obj_name, i)) save_mesh(mesh, None, save_dir) print('Saved to {}'.format(save_dir)) obj_list.append(save_dir)


- smplh2smplx.yaml
```yaml
datasets:
    mesh_folder:
        data_folder: 'transfer_data/meshes/smplh'
deformation_transfer_path: 'transfer_data/smplh2smplx_deftrafo_setup.pkl'
# mask_ids_fname: 'smplx_mask_ids.npy'
mask_ids_fname: 'transfer_data/smplx_mask_ids.npy'
summary_steps: 100

edge_fitting:
    per_part: False

optim:
    type: 'trust-ncg'
    maxiters: 100
    gtol: 1e-06

body_model:
    model_type: "smplx"
    gender: "neutral"
#    folder: "transfer_data/body_models"
    folder: '../Dataset/amass_contacts/models/smplx/SMPLX_MALE.npz'
    use_compressed: False
    use_face_contour: True
    smplx:
        betas:
            num: 10
        expression:
            num: 10

Input: image model_transfer Output: image

Question: I suspect the input .obj file is incorrect, even though the input “looks” correct. Is there any requirements for the transfer_model input?

Thank you for taking the time to solve our problems in advance!

Best

kbrodt commented 3 years ago

I have the same issue. For some poses of SMPL meshes I get weird result.

Luciano07 commented 3 years ago

I had the same issue, this is because trimesh changes the vertices values by default. add the flag "process=False" when you load the mesh:

mesh = trimesh.Trimesh(vertices=c2c(all_step_vertices[i]), faces=faces, vertex_colors=np.tile(colors['grey'], (10475, 1)),process=False)

After that, should work!

gngdb commented 2 years ago

I spent days debugging this, the authors responded and this was the same problem. I wish I'd seen this issue.