MarilynKeller / SKEL

Release for the Siggraph Asia 2023 SKEL paper "From Skin to Skeleton: Towards Biomechanically Accurate 3D Digital Humans".
https://skel.is.tue.mpg.de/
Other
196 stars 24 forks source link

Generation of Skeletons for infants/kids #17

Closed nshreyasvi closed 2 months ago

nshreyasvi commented 3 months ago

Hello, I was trying to run SKEL for SMPL meshes that were extracted for children and infants and would like to know if there is a way to optimize the steps to get accurate joint locations for them? I tried with OSSO and was not able to get a good joint location.

MarilynKeller commented 3 months ago

Hi, if you just need the anatomical joints locations, you can directly regress them from your SMPL meshes by running:

# smpl_mesh_verts : vertices of your SMPL mesh
# J : regressed anatomical joint locations
skel_model = SKEL(gender)
J = torch.einsum('bik,ji->bjk', [smpl_mesh_verts, skel_model.J_regressor_osim])

If you need the bone orientations too then directly fitting SKEL to your SMPL would be the way to go.

nshreyasvi commented 3 months ago

Hello, thank you so much for the quick response. I will try it. I was also trying to convert frame by frame SMPL meshes into SKEL sequences but I was unsure on how to do the same. I currently have .obj and .pkl files that was generated using the smplify-x pipeline and wanted to know how can I convert them into SKEL sequences? I also wanted to know that should I have input as SMPL, SMPL-H or SMPL-X for conversion to SKEL?

MarilynKeller commented 3 months ago

I see, so you will need the SMPL parameters to run SKEL. So the input is SMPL, not SMPL-X.

If you have SMPL-X meshes, maybe this can help for the conversion: https://github.com/vchoutas/smplx/blob/main/transfer_model/README.md

nshreyasvi commented 3 months ago

Hello, Thank you so much for the information. So, I have generated SMPL .obj files. I was unsure how can I convert these SMPL obj files for individual frames into a SMPL sequence? Does the merge_output.py script inside the transfer model generates SMPL sequence file?

I tried to run align examples/align_to_SMPL_frame.py script to my .pkl SMPL output that I generated. But I am getting the error :

File "SKEL/skel/alignment/utils.py" in line 64 in load_smpl_seq
    poses = np.concatenate([data_dict['global_orient_axis_angle'], data_dict['body_pose_axis_angle']], axis=-1)
KeyError: 'global_orient_axis_angle'

I did the same on merged_output.pkl file that was generated using the merged_output.py script in transfer_model folder but I get the same output.

If I run it on the examples provided it seems to be working fine.

I wanted to know if there is a difference between the SMPL .pkl files generated from SMPLify-x library compared to the ones that are used in the examples?

MarilynKeller commented 3 months ago

I think you are on the right track, you just need to add support for your pkl dictionary in the load_smpl_seq function in SKEL/skel/alignment/utils.py to be able to load the SMPL pkl you got.

Basically the issue is that everyone tends to store the SMPL parameters with different key names. So I only support some names.

Which are the keys present in the .pkl you got ? You can check with:

data_dict = pickle.load(open(your_pkl, 'rb'))
print(data_dict.items())

You then need to modify the load_smpl_seq function to return a dictionary with the following keys:

https://github.com/MarilynKeller/SKEL/blob/832f9a589215c934b4fadf1b5d03f1dab5ef7999/skel/alignment/utils.py#L94C1-L99C46

    out_dict['trans'] = data_fixed['trans'] # Fx3 matrix
    out_dict['poses'] = data_fixed['poses'] # Fx72
    out_dict['betas'] = data_fixed['betas'] # Fx10
    out_dict['gender'] = data_fixed['gender'] # ('male' or 'female')

Where F is the number of frames. Look at the shape of what you get in your pkl to build this output dictionnary

nshreyasvi commented 3 months ago

Hello, Thank you for the quick response. I checked the keys for the .pkl file and they are as follows:

dict_keys(['transl', 'global_orient', 'body_pose', 'betas', 'vertices', 'joints', 'full_pose', 'v_shaped', 'faces'])

I was unable to find

'body_pose_axis_angle', 'global_orient_axis_angle'

or anything similar in the keys. I am checking the keys using the following method:

import pickle

data_dict = pickle.load(open('proband_gen_109_smpl.pkl','rb'))
print(data_dict.keys())

if I use .items(), it is returning the full pkl file if I am not wrong:

dict_items([('transl', None), ('global_orient', tensor([[[[-0.4074, -0.0305,  0.9127],
          [ 0.0766,  0.9948,  0.0674],
          [-0.9100,  0.0974, -0.4029]]]], device='cuda:0', requires_grad=True)), ('body_pose', tensor([[[[ 9.9357e-01, -9.9342e-02,  5.4387e-02],
          [ 8.3551e-02,  9.6712e-01,  2.4019e-01],
          [-7.6460e-02, -2.3410e-01,  9.6920e-01]],

         [[ 9.8969e-01, -1.3153e-02,  1.4264e-01],
          [-4.0235e-02,  9.3016e-01,  3.6495e-01],
          [-1.3748e-01, -3.6692e-01,  9.2004e-01]],

         [[ 9.9857e-01,  4.9139e-02, -2.1230e-02],
          [-5.3353e-02,  9.4582e-01, -3.2028e-01],
          [ 4.3414e-03,  3.2095e-01,  9.4709e-01]],

         [[ 9.8574e-01,  1.5929e-01,  5.4180e-02],
          [-1.0600e-01,  8.3804e-01, -5.3522e-01],
          [-1.3066e-01,  5.2184e-01,  8.4298e-01]],

         [[ 9.8629e-01,  2.0216e-02,  1.6378e-01],
          [ 9.1960e-02,  7.5675e-01, -6.4721e-01],
          [-1.3702e-01,  6.5340e-01,  7.4451e-01]],

         [[ 9.9313e-01, -7.8594e-02, -8.6730e-02],
          [ 7.5275e-02,  9.9632e-01, -4.0901e-02],
          [ 8.9626e-02,  3.4092e-02,  9.9539e-01]],

         [[ 9.6111e-01, -1.8494e-02,  2.7555e-01],
          [-2.8381e-02,  9.8586e-01,  1.6516e-01],
          [-2.7471e-01, -1.6655e-01,  9.4699e-01]],

         [[ 9.7049e-01, -1.8595e-01,  1.5351e-01],
          [ 1.6330e-01,  9.7526e-01,  1.4897e-01],
          [-1.7742e-01, -1.1950e-01,  9.7685e-01]],

         [[ 9.9966e-01, -1.7734e-02, -1.9077e-02],
          [ 1.7578e-02,  9.9981e-01, -8.2765e-03],
          [ 1.9220e-02,  7.9383e-03,  9.9978e-01]],

         [[ 9.7814e-01, -1.2456e-01, -1.6650e-01],
          [ 1.4545e-01,  9.8209e-01,  1.1975e-01],
          [ 1.4860e-01, -1.4135e-01,  9.7874e-01]],

         [[ 9.9316e-01,  9.1814e-02,  7.2110e-02],
          [-9.9397e-02,  9.8897e-01,  1.0977e-01],
          [-6.1237e-02, -1.1619e-01,  9.9134e-01]],

         [[ 9.9980e-01, -1.4235e-03,  1.9745e-02],
          [ 4.9795e-03,  9.8343e-01, -1.8124e-01],
          [-1.9160e-02,  1.8130e-01,  9.8324e-01]],

         [[ 9.8103e-01,  1.6314e-01, -1.0468e-01],
          [-1.7003e-01,  9.8357e-01, -6.0636e-02],
          [ 9.3068e-02,  7.7284e-02,  9.9266e-01]],

         [[ 9.6943e-01, -2.3548e-01,  6.8965e-02],
          [ 2.4012e-01,  9.6826e-01, -6.9311e-02],
          [-5.0455e-02,  8.3752e-02,  9.9521e-01]],

         [[ 9.9437e-01, -9.3561e-02,  4.9733e-02],
          [ 9.5646e-02,  9.9456e-01, -4.1345e-02],
          [-4.5594e-02,  4.5869e-02,  9.9791e-01]],

         [[ 5.6598e-01,  8.0474e-01, -1.7904e-01],
          [-8.0211e-01,  5.8770e-01,  1.0594e-01],
          [ 1.9048e-01,  8.3646e-02,  9.7812e-01]],

         [[ 5.7762e-01, -7.9515e-01,  1.8463e-01],
          [ 8.0856e-01,  5.8839e-01,  4.4641e-03],
          [-1.1218e-01,  1.4671e-01,  9.8280e-01]],

         [[ 7.1477e-01, -3.9265e-01, -5.7873e-01],
          [ 1.0183e-01,  8.7713e-01, -4.6934e-01],
          [ 6.9191e-01,  2.7654e-01,  6.6692e-01]],

         [[ 6.6602e-01,  2.9023e-01,  6.8715e-01],
          [-6.2625e-02,  9.3971e-01, -3.3620e-01],
          [-7.4330e-01,  1.8088e-01,  6.4404e-01]],

         [[ 9.5850e-01, -2.6213e-01, -1.1210e-01],
          [ 2.4158e-01,  9.5558e-01, -1.6884e-01],
          [ 1.5138e-01,  1.3475e-01,  9.7925e-01]],

         [[ 9.8810e-01,  5.6018e-02,  1.4322e-01],
          [-7.2897e-02,  9.9063e-01,  1.1546e-01],
          [-1.3541e-01, -1.2453e-01,  9.8293e-01]],

         [[ 9.9997e-01,  6.6186e-04,  7.6575e-03],
          [-5.4350e-04,  9.9988e-01, -1.5447e-02],
          [-7.6668e-03,  1.5442e-02,  9.9985e-01]],

         [[ 9.9993e-01,  7.9865e-03,  8.9867e-03],
          [-7.9270e-03,  9.9995e-01, -6.6397e-03],
          [-9.0393e-03,  6.5680e-03,  9.9994e-01]]]], device='cuda:0',
       requires_grad=True)), ('betas', tensor([[-0.6629,  0.7159, -1.0633,  0.7916,  0.2928,  0.5894,  0.5404, -0.0013,
          0.2153,  0.3502]], device='cuda:0', requires_grad=True)), ('vertices', tensor([[[ 0.2454,  0.7616, -0.0912],
         [ 0.2459,  0.7457, -0.0883],
         [ 0.2344,  0.7480, -0.0957],
         ...,
         [ 0.1773,  0.7288,  0.0435],
         [ 0.1794,  0.7296,  0.0434],
         [ 0.1813,  0.7262,  0.0449]]], device='cuda:0', requires_grad=True)), ('joints', tensor([[[-1.1440e-03,  1.9436e-01, -2.0686e-02],
         [-3.5441e-02,  1.1427e-01, -8.3366e-02],
         [ 1.9788e-02,  1.0581e-01,  3.1882e-02],
         [-1.7720e-02,  2.8924e-01, -2.5536e-03],
         [ 2.0989e-02, -2.2323e-01, -2.1302e-01],
         [ 1.6887e-01, -2.3085e-01, -2.6744e-02],
         [ 1.1093e-02,  4.0722e-01, -1.6025e-02],
         [-8.0993e-02, -5.8431e-01, -1.3546e-01],
         [ 4.7759e-02, -5.8809e-01,  3.7214e-02],
         [ 4.5332e-02,  4.4444e-01, -2.6570e-02],
         [-2.9515e-02, -6.4322e-01, -2.3448e-01],
         [ 1.2353e-01, -6.4730e-01, -4.2921e-02],
         [ 7.1079e-02,  6.3867e-01, -1.4026e-02],
         [ 3.0726e-02,  5.6341e-01, -8.5529e-02],
         [ 6.6109e-02,  5.5068e-01,  5.2583e-02],
         [ 1.4075e-01,  6.6969e-01, -3.6983e-02],
         [ 1.6315e-02,  5.8596e-01, -1.6872e-01],
         [ 9.2976e-02,  5.5436e-01,  1.3983e-01],
         [-6.8623e-02,  3.6889e-01, -2.6339e-01],
         [ 3.9844e-02,  3.3062e-01,  2.1975e-01],
         [ 5.5290e-02,  1.9724e-01, -3.7001e-01],
         [ 1.7666e-01,  1.2965e-01,  2.0083e-01],
         [ 9.8277e-02,  1.4633e-01, -4.1162e-01],
         [ 2.1856e-01,  6.4202e-02,  1.8932e-01],
         [ 2.4506e-01,  6.6283e-01, -6.5467e-02],
         [ 2.4576e-01,  7.0305e-01, -2.2619e-02],
         [ 2.2914e-01,  7.1651e-01, -8.4161e-02],
         [ 1.7200e-01,  7.2144e-01,  4.0083e-02],
         [ 1.3740e-01,  7.4942e-01, -8.9084e-02],
         [ 3.9239e-02, -6.4516e-01, -2.6401e-01],
         [-3.6486e-02, -6.4726e-01, -2.7653e-01],
         [-1.3091e-01, -6.1043e-01, -1.0013e-01],
         [ 1.3758e-01, -6.4200e-01, -1.1542e-01],
         [ 1.6005e-01, -6.6687e-01, -4.2662e-02],
         [ 1.0327e-02, -6.2511e-01,  8.1667e-02],
         [ 1.6179e-01,  1.3077e-01, -3.4380e-01],
         [ 1.8298e-01,  1.0401e-01, -4.2858e-01],
         [ 1.7017e-01,  9.8983e-02, -4.6085e-01],
         [ 1.4132e-01,  1.0354e-01, -4.7123e-01],
         [ 9.9134e-02,  1.1204e-01, -4.6991e-01],
         [ 2.5472e-01,  1.0073e-01,  1.0534e-01],
         [ 2.8889e-01,  2.0724e-02,  1.5009e-01],
         [ 2.8193e-01, -3.2395e-03,  1.7613e-01],
         [ 2.5825e-01, -6.9742e-03,  1.9711e-01],
         [ 2.1922e-01,  2.5919e-04,  2.1901e-01]]], device='cuda:0',
       requires_grad=True)), ('full_pose', tensor([[[[-4.0741e-01, -3.0497e-02,  9.1274e-01],
          [ 7.6580e-02,  9.9478e-01,  6.7420e-02],
          [-9.1003e-01,  9.7365e-02, -4.0295e-01]],

         [[ 9.9357e-01, -9.9342e-02,  5.4387e-02],
          [ 8.3551e-02,  9.6712e-01,  2.4019e-01],
          [-7.6460e-02, -2.3410e-01,  9.6920e-01]],

         [[ 9.8969e-01, -1.3153e-02,  1.4264e-01],
          [-4.0235e-02,  9.3016e-01,  3.6495e-01],
          [-1.3748e-01, -3.6692e-01,  9.2004e-01]],

         [[ 9.9857e-01,  4.9139e-02, -2.1230e-02],
          [-5.3353e-02,  9.4582e-01, -3.2028e-01],
          [ 4.3414e-03,  3.2095e-01,  9.4709e-01]],

         [[ 9.8574e-01,  1.5929e-01,  5.4180e-02],
          [-1.0600e-01,  8.3804e-01, -5.3522e-01],
          [-1.3066e-01,  5.2184e-01,  8.4298e-01]],

         [[ 9.8629e-01,  2.0216e-02,  1.6378e-01],
          [ 9.1960e-02,  7.5675e-01, -6.4721e-01],
          [-1.3702e-01,  6.5340e-01,  7.4451e-01]],

         [[ 9.9313e-01, -7.8594e-02, -8.6730e-02],
          [ 7.5275e-02,  9.9632e-01, -4.0901e-02],
          [ 8.9626e-02,  3.4092e-02,  9.9539e-01]],

         [[ 9.6111e-01, -1.8494e-02,  2.7555e-01],
          [-2.8381e-02,  9.8586e-01,  1.6516e-01],
          [-2.7471e-01, -1.6655e-01,  9.4699e-01]],

         [[ 9.7049e-01, -1.8595e-01,  1.5351e-01],
          [ 1.6330e-01,  9.7526e-01,  1.4897e-01],
          [-1.7742e-01, -1.1950e-01,  9.7685e-01]],

         [[ 9.9966e-01, -1.7734e-02, -1.9077e-02],
          [ 1.7578e-02,  9.9981e-01, -8.2765e-03],
          [ 1.9220e-02,  7.9383e-03,  9.9978e-01]],

         [[ 9.7814e-01, -1.2456e-01, -1.6650e-01],
          [ 1.4545e-01,  9.8209e-01,  1.1975e-01],
          [ 1.4860e-01, -1.4135e-01,  9.7874e-01]],

         [[ 9.9316e-01,  9.1814e-02,  7.2110e-02],
          [-9.9397e-02,  9.8897e-01,  1.0977e-01],
          [-6.1237e-02, -1.1619e-01,  9.9134e-01]],

         [[ 9.9980e-01, -1.4235e-03,  1.9745e-02],
          [ 4.9795e-03,  9.8343e-01, -1.8124e-01],
          [-1.9160e-02,  1.8130e-01,  9.8324e-01]],

         [[ 9.8103e-01,  1.6314e-01, -1.0468e-01],
          [-1.7003e-01,  9.8357e-01, -6.0636e-02],
          [ 9.3068e-02,  7.7284e-02,  9.9266e-01]],

         [[ 9.6943e-01, -2.3548e-01,  6.8965e-02],
          [ 2.4012e-01,  9.6826e-01, -6.9311e-02],
          [-5.0455e-02,  8.3752e-02,  9.9521e-01]],

         [[ 9.9437e-01, -9.3561e-02,  4.9733e-02],
          [ 9.5646e-02,  9.9456e-01, -4.1345e-02],
          [-4.5594e-02,  4.5869e-02,  9.9791e-01]],

         [[ 5.6598e-01,  8.0474e-01, -1.7904e-01],
          [-8.0211e-01,  5.8770e-01,  1.0594e-01],
          [ 1.9048e-01,  8.3646e-02,  9.7812e-01]],

         [[ 5.7762e-01, -7.9515e-01,  1.8463e-01],
          [ 8.0856e-01,  5.8839e-01,  4.4641e-03],
          [-1.1218e-01,  1.4671e-01,  9.8280e-01]],

         [[ 7.1477e-01, -3.9265e-01, -5.7873e-01],
          [ 1.0183e-01,  8.7713e-01, -4.6934e-01],
          [ 6.9191e-01,  2.7654e-01,  6.6692e-01]],

         [[ 6.6602e-01,  2.9023e-01,  6.8715e-01],
          [-6.2625e-02,  9.3971e-01, -3.3620e-01],
          [-7.4330e-01,  1.8088e-01,  6.4404e-01]],

         [[ 9.5850e-01, -2.6213e-01, -1.1210e-01],
          [ 2.4158e-01,  9.5558e-01, -1.6884e-01],
          [ 1.5138e-01,  1.3475e-01,  9.7925e-01]],

         [[ 9.8810e-01,  5.6018e-02,  1.4322e-01],
          [-7.2897e-02,  9.9063e-01,  1.1546e-01],
          [-1.3541e-01, -1.2453e-01,  9.8293e-01]],

         [[ 9.9997e-01,  6.6186e-04,  7.6575e-03],
          [-5.4350e-04,  9.9988e-01, -1.5447e-02],
          [-7.6668e-03,  1.5442e-02,  9.9985e-01]],

         [[ 9.9993e-01,  7.9865e-03,  8.9867e-03],
          [-7.9270e-03,  9.9995e-01, -6.6397e-03],
          [-9.0393e-03,  6.5680e-03,  9.9994e-01]]]], device='cuda:0',
       requires_grad=True)), ('v_shaped', None), ('faces', array([[   1,    2,    0],
       [   0,    2,    3],
       [   2,    1,    4],
       ...,
       [4805, 3511, 6309],
       [3511, 1330, 6309],
       [6309, 1330, 4687]], dtype=uint32))])

Could you let me know where can I find these two variables ('body_pose_axis_angle', 'global_orient_axis_angle') within the .pkl file?

MarilynKeller commented 3 months ago

Alright, thanks for sharing the output

So you have: data_in = dict_keys(['transl', 'global_orient', 'body_pose', 'betas', 'vertices', 'joints', 'full_pose', 'v_shaped', 'faces'])

And you need: out_dict['trans'] = data_fixed['trans'] # Fx3 matrix out_dict['poses'] = data_fixed['poses'] # Fx72 out_dict['betas'] = data_fixed['betas'] # Fx10 out_dict['gender'] = data_fixed['gender'] # ('male' or 'female')

So this should work: out_dict['trans'] = data_in['transl'] out_dict['poses'] = data_in['full_pose'] out_dict['betas'] = data_in['betas'] out_dict['gender'] = 'male' #( or 'female')

nshreyasvi commented 3 months ago

Hello, Thank you, I changed the variable names but I am currently getting the following error:

Traceback (most recent call last):
  File "examples/align_to_SMPL_frame.py", line 53, in <module>
    skel_seq = skel_fitter.run_fit(smpl_data['trans'], 
  File "/home/scai/Downloads/Shrey/SKEL/skel/alignment/aligner.py", line 83, in run_fit
    body_params = self._init_params(betas_in, poses_in, trans_in, skel_data_init)
  File "/home/scai/Downloads/Shrey/SKEL/skel/alignment/aligner.py", line 154, in _init_params
    poses_skel[:, :3] = poses_smpl[:, :3] # Global orient are similar between SMPL and SKEL, so init with SMPL angles
RuntimeError: expand(torch.cuda.FloatTensor{[3, 3, 3]}, size=[1, 3]): the number of sizes provided (2) must be greater or equal to the number of dimensions in the tensor (3)
MarilynKeller commented 3 months ago

Could you print the shape of each of these tensors after you initialized them?

out_dict['trans'] out_dict['poses'] out_dict['betas']

nshreyasvi commented 2 months ago

Hello, The shapes are as follows:

out_dict['trans'] = None
out_dict['poses'].shape or out_dict['full_pose'].shape = torch.Size([1, 24, 3, 3])
out_dict['betas'].shape = torch.Size([1, 10])
MarilynKeller commented 2 months ago

Oh I see, the pose parameters are as 3x3 matrix. You can not use this unfortunately as SMPL parameters. Do you have anything that is of shape 1x24x3 or 1x72 or 1x69 ?

Again you need these SMPL parameters beta (1x10) and theta (1x72) to use my code to fit SKEL.

nshreyasvi commented 2 months ago

Hello, Sorry for the delays in response. I checked the shape of each of the parameters in the SMPL model and they have the following shape:

transl = None
global_orient = torch.Size([1, 1, 3, 3])
body_pose = torch.Size([1, 23, 3, 3])
betas = torch.Size([1, 10])
vertices = torch.Size([1, 6890, 3])
joints = torch.Size([1, 45, 3])
full_pose = torch.Size([1, 24, 3, 3])
v_shaped = None
faces = (13776, 3)

I see that the beta key is available in the correct shape but I could not find anything which was of the shape of theta (1X72). I believe that body_pose and full_pose seems to have the first 3 dimensions correct (1X24X3) but it seems to have an extra dimension.

I wanted to know if there is a way I can use these keys to generate the theta and pose parameters as they should be transferable? I can then write a small function to convert the generated SMPL model into the format used by SKEL so that it converts them in the correct format. I also tested out the SKEL model by just reshaping the full_body and body_pose parameters but it seems to twist the SMPL bodies completely. But the SKEL model seems to work then. I think that the issue is in conversion of the SMPL keys into the keys that can be taken as input here. If there is any resources you could refer me to, that would be great. I have attached the pkl files for the SMPL models I am using along with this message as well.

proband_gen_1.zip

The script to check the contents for the .pkl file is as follows:

import pickle

data_dict = pickle.load(open('proband_gen_186_smpl.pkl','rb'))
print(data_dict.keys())
MarilynKeller commented 2 months ago

Hi, so you are close. The SMPL pose parameters need to be expressed in Nj Rodrigues angles (3 parameters per joint, where Nj=24 is the number of joints of SMPL). What you have is Nj rotation matrices instead. I see two options (option 2 might be better):

Option 1) So you would "just" need to transform each of these rotation matrix to the rodrigues angle representation. You can do that using opencv

$pip install opencv-python
$ python
> poses_params = np.zeros((F,24,3))
> poses_params[f,i] = cv2.Rodrigues(pose[f,i]) where f in a frame (you only have one), and i the joint (from 0 to 23). 

Option 2) I am not sure in the first place why transfer_models return you matrices and not pose parameters. I checked in their code and you could just modify it to skip the transformation of the pose parameter to matrices:

Edit the transfer_model code here https://github.com/vchoutas/smplx/blob/1265df7ba545e8b00f72e7c557c766e15c71632f/transfer_model/transfer_model.py#L382 to change it to :

for key, var in var_dict.items():
            # Simply pass the variable
            param_dict[key] = var

And rerun the transfer. The output dictionary should have directly the proper pose and orient fields.

Good luck!

nshreyasvi commented 2 months ago

Hello, I changed the code as per the suggestion, but I am getting the following error in smplx

The line is linked here: https://github.com/vchoutas/smplx/blob/1265df7ba545e8b00f72e7c557c766e15c71632f/smplx/body_models.py#L479

  File "/home/shrey/smplx/smplx/body_models.py", line 479, in forward
    [global_orient.reshape(-1, 1, 3, 3),
RuntimeError: shape '[-1, 1, 3, 3]' is invalid for input of size 3

I further also made a script to convert the full_pose using cv2.Rodrigues method. The script I am using is as follows:

import cv2
import numpy as np
import pickle
import torch

data_dict = pickle.load(open('proband_gen_186_smpl.pkl','rb'))
print(data_dict.keys())

#print(data_dict['full_pose'][0,1])

#poses_params = np.zeros((1,24,3))

for f in range(0,len(data_dict['full_pose'])):
    for i in range(0,24):
        poses_params = (data_dict['full_pose'][f,i]).cpu().detach().numpy()
        poses_params = np.array(poses_params)
        print(poses_params.shape)
        poses_params_test = cv2.Rodrigues(poses_params)
        print(np.array(poses_params_test).shape)
        #data_dict['full_pose'][f,i] = torch.tensor(poses_params)

# Open a file and use dump() 
#with open('new_model_changed.pkl', 'wb') as file: 
    # A new file will be created 
    #pickle.dump(data_dict, file) 

However, the output shape that I am obtaining from cv2.Rodrigues tends to be a tuple rather than an array. I believe that I won't be able to generate a tensor if I am not using an np.array. Furthermore, the shape of the tuple (when I convert it into an array) doesn't seem to match 3X3.

Could you let me know how can I resolve it so that the format tends to be the same for the output or if I should use any other script/library/version of SMPLify-x to generate the SMPL meshes from video/images? I am currently using this library

nshreyasvi commented 2 months ago

Hello, I was able to solve the issue by using the same HMR output format used here. I further changed line 64 in skel/alignment/utils.py and changed the values of global_orient_axis_angle and body_pose_axis_angle to global_orient and body_pose. It seems to solve the issue.