Simplify code.

This commit is contained in:
gulvarol
2019-07-10 14:52:40 +02:00
parent 095e65e498
commit 89f5c60799
2 changed files with 29 additions and 24 deletions

View File

@ -4,18 +4,19 @@ from smpl.pytorch import rodrigues_layer
def th_posemap_axisang(pose_vectors):
'''
Converts axis-angle to rotmat
pose_vectors (Tensor (batch_size x 72)): pose parameters in axis-angle representation
'''
rot_nb = int(pose_vectors.shape[1] / 3)
rot_mats = []
for joint_idx in range(rot_nb - 1):
joint_idx_val = joint_idx + 1
axis_ang = pose_vectors[:, joint_idx_val * 3:(joint_idx_val + 1) * 3]
for joint_idx in range(rot_nb):
axis_ang = pose_vectors[:, joint_idx * 3:(joint_idx + 1) * 3]
rot_mat = rodrigues_layer.batch_rodrigues(axis_ang)
rot_mats.append(rot_mat)
# rot_mats = torch.stack(rot_mats, 1).view(-1, 15 *9)
rot_mats = torch.cat(rot_mats, 1)
pose_maps = subtract_flat_id(rot_mats)
return pose_maps, rot_mats
return rot_mats
def th_with_zeros(tensor):