Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions manopth/rotproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ def batch_rotprojs(batches_rotmats):
for rot_idx, rotmat in enumerate(batch_rotmats):
# GPU implementation of svd is VERY slow
# ~ 2 10^-3 per hit vs 5 10^-5 on cpu
U, S, V = rotmat.cpu().svd()
rotmat = torch.matmul(U, V.transpose(0, 1))
_device = rotmat.device
U, S, V_T = torch.linalg.svd(rotmat.cpu())
rotmat = torch.matmul(U, V_T)
orth_det = rotmat.det()
# Remove reflection
if orth_det < 0:
rotmat[:, 2] = -1 * rotmat[:, 2]

rotmat = rotmat.cuda()
rotmat = rotmat.to(_device)
proj_batch_rotmats.append(rotmat)
proj_rotmats.append(torch.stack(proj_batch_rotmats))
return torch.stack(proj_rotmats)