Jeff-sjtu / HybrIK

Official code of "HybrIK: A Hybrid Analytical-Neural Inverse Kinematics Solution for 3D Human Pose and Shape Estimation", CVPR 2021
MIT License
1.21k stars 147 forks source link

About the simple3dposeBaseSMPL24.py #166

Closed Hao-hui closed 1 year ago

Hao-hui commented 1 year ago

We trained your code from scratch using 24 keypoints, but when we reached this, an error occurred due to the dimensions of rot_mat_chain[parents[i]] --> torch.Size([32, 2, 3, 3]), while rot_mat --> torch.Size([32, 5, 3, 3]), this caused an error in the torch.matmul operation as follows. I hope you can help me solve it. I don't know if it's a problem with the code itself or if I did something wrong in my operation.

Traceback (most recent call last): File "/home//anaconda3/envs/hyb/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap fn(i, args) File "/home/newdisk/HybrIK-ori/scripts/train_smpl.py", line 328, in main_worker loss, acc17 = train(opt, train_loader, m, criterion, optimizer, writer) File "/home/newdisk/HybrIK-ori/scripts/train_smpl.py", line 57, in train output = m(inps, trans_inv, intrinsic_param, root, depth_factor, None) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 511, in forward output = self.module(*inputs[0], *kwargs[0]) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/home/newdisk/HybrIK-ori/hybrik/models/simple3dposeBaseSMPL24.py", line 332, in forward output = self.smpl.hybrik( File "/home/newdisk//HybrIK-ori/hybrik/models/layers/smpl/SMPL.py", line 256, in hybrik vertices, new_joints, rot_mats, joints_from_verts = hybrik( File "/home/HybrIK-ori/hybrik/models/layers/smpl/lbs.py", line 357, in hybrik rot_mats, rotate_rest_pose = batch_inverse_kinematics_transform_naive( File "/home/HybrIK-ori/hybrik/models/layers/smpl/lbs.py", line 867, in batch_inverse_kinematics_transform_naive rot_mat_chain[:, indices] = torch.matmul( RuntimeError: The size of tensor a (2) must match the size of tensor b (5) at non-singleton dimension 1

Dipankar1997161 commented 10 months ago

We trained your code from scratch using 24 keypoints, but when we reached this, an error occurred due to the dimensions of rot_mat_chain[parents[i]] --> torch.Size([32, 2, 3, 3]), while rot_mat --> torch.Size([32, 5, 3, 3]), this caused an error in the torch.matmul operation as follows. I hope you can help me solve it. I don't know if it's a problem with the code itself or if I did something wrong in my operation.

Traceback (most recent call last): File "/home//anaconda3/envs/hyb/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap fn(i, args) File "/home/newdisk/HybrIK-ori/scripts/train_smpl.py", line 328, in main_worker loss, acc17 = train(opt, train_loader, m, criterion, optimizer, writer) File "/home/newdisk/HybrIK-ori/scripts/train_smpl.py", line 57, in train output = m(inps, trans_inv, intrinsic_param, root, depth_factor, None) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 511, in forward output = self.module(*inputs[0], *kwargs[0]) File "/home/anaconda3/envs/hyb/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/home/newdisk/HybrIK-ori/hybrik/models/simple3dposeBaseSMPL24.py", line 332, in forward output = self.smpl.hybrik( File "/home/newdisk//HybrIK-ori/hybrik/models/layers/smpl/SMPL.py", line 256, in hybrik vertices, new_joints, rot_mats, joints_from_verts = hybrik( File "/home/HybrIK-ori/hybrik/models/layers/smpl/lbs.py", line 357, in hybrik rot_mats, rotate_rest_pose = batch_inverse_kinematics_transform_naive( File "/home/HybrIK-ori/hybrik/models/layers/smpl/lbs.py", line 867, in batch_inverse_kinematics_transform_naive rot_mat_chain[:, indices] = torch.matmul( RuntimeError: The size of tensor a (2) must match the size of tensor b (5) at non-singleton dimension 1

hey @Hao-hui , did you solve the error in this?? if so, can you help a bit on how to resolve this

Hao-hui commented 10 months ago

hey @Hao-hui , did you solve the error in this?? if so, can you help a bit on how to resolve this

@Dipankar1997161 hybrik\hybrik\models\layers\smpl\SMPL.py line264 *rot_mats = rotmat_to_quat(rot_mats).reshape(batch_size, 24 4)**

Uncommenting this line can make the code run normally, but it's not clear how much of an impact it has. I consulted the author, and they said that the code for 24 joints is too old and they can't remember it clearly, so they recommended using the one with 29 joint points. We can communicate promptly if there are any updates. Best wishes.