GanHand icon indicating copy to clipboard operation
GanHand copied to clipboard

RuntimeError: mat1 dim 1 must match mat2 dim 0

Open anjugopinath opened this issue 3 years ago • 8 comments

On running the command, I am getting the below error:

File "/home/anju/CodeSpace/GanHand/utils/forward_kinematics_3dof.py", line 297, in get_hand MANO.th_posedirs, th_pose_map.transpose(0, 1)).permute(2, 0, 1) RuntimeError: mat1 dim 1 must match mat2 dim 0

anjugopinath avatar Mar 03 '21 06:03 anjugopinath

Hi, I updated the forward kinematics file and the model file with the last versions that I'm able to run at my PC. Could you try it again? I think it's a matter of tensor shapes in the matmul operation. So, if it fails, could you look at the tensor shapes of MANO.th_posedirs and th_pose_map?

enriccorona avatar Mar 03 '21 14:03 enriccorona

Hi, I updated the forward kinematics file and the model file with the last versions that I'm able to run at my PC. Could you try it again? I think it's a matter of tensor shapes in the matmul operation. So, if it fails, could you look at the tensor shapes of MANO.th_posedirs and th_pose_map?

Thanks a lot for your work. And when I try to run the latest test code you provided, this error also occurs. And the tensor shapes you mentioned are as follows.

  • The tensor shapes of MANO.th_posedirs: torch.Size([778, 3, 135])
  • The tensor shapes of th_pose_map: torch.Size([51, 144])

hatimwen avatar Mar 12 '21 02:03 hatimwen

Hi, I updated the forward kinematics file and the model file with the last versions that I'm able to run at my PC. Could you try it again? I think it's a matter of tensor shapes in the matmul operation. So, if it fails, could you look at the tensor shapes of MANO.th_posedirs and th_pose_map?

Hi,

I replaced the repo with the latest files. But, I am getting this error:

Traceback (most recent call last): File "test.py", line 443, in Test() File "test.py", line 257, in init self._display_visualizer_test(20, self._total_steps) File "test.py", line 321, in _display_visualizer_test self._model.forward(keep_data_for_visuals=True) File "/home/anju/CodeSpace/GanHand/models/ganhand.py", line 229, in forward handfullpose_list, touching_indexs, loss_distance, loss_angle, loss_angle_2ndjoint, loss_angle_3rdjoint = fk.optimize_hand(handfullpose[i].unsqueeze(0), R[i].unsqueeze(0), T[i].unsqueeze(0), self._input_obj_resampled_verts[i][self._input_object_id[i]]) File "/home/anju/CodeSpace/GanHand/utils/forward_kinematics_3dof.py", line 494, in optimize_hand meshes, _ = get_hand(handfullpose_repeated, R.repeat(num_samples, 1), T.repeat(num_samples, 1)) File "/home/anju/CodeSpace/GanHand/utils/forward_kinematics_3dof.py", line 299, in get_hand MANO.th_posedirs, th_pose_map.transpose(0, 1)).permute(2, 0, 1) RuntimeError: mat1 dim 1 must match mat2 dim 0

So, I printed the shape

print( MANO.th_posedirs.shape,th_pose_map.shape,th_pose_map.transpose(0, 1).shape)

This is the result I got torch.Size([778, 3, 135]) torch.Size([51, 144]) torch.Size([144, 51])

Could you tell me how to fix it please?

anjugopinath avatar Mar 30 '21 05:03 anjugopinath

Hi, I meet the same problem. Did you fix it?

yimingli1998 avatar Apr 27 '21 03:04 yimingli1998

Solved by issue #3

SeanChenxy avatar May 12 '21 08:05 SeanChenxy

Hi, I also encounter the same problem, how to solve it?

lihuanihao avatar Jul 29 '22 03:07 lihuanihao

Hi, I meet the same problem, can you help me?

lxhy9799 avatar Aug 12 '22 03:08 lxhy9799

I solved this error. I found MANO.th_posedirs.shape is [778, 3, 135] and th_pose_map.shape is [51,144]. If th_pose_map.shape become [51,135], then the malmul is right. So I refered the hassony/manopth code, and found there are some different details in function manolayer.forward() , hassony'manolayer.forward() did 'th_pose_map = th_pose_map[:, 9:]',make th_pose_map.shape [1,144] become [1,135]. Now I can run the test.py. But I still don't get the right result until now.

rather1015 avatar Feb 27 '24 14:02 rather1015