Skip to content

Commit

Permalink
Revise to be consistent with paper
Browse files Browse the repository at this point in the history
  • Loading branch information
XingangPan committed Jul 18, 2023
1 parent c5e88b3 commit d0422b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions viz/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,11 @@ def _render_drag_impl(self, res,
distance = ((xx.to(self._device) - point[0])**2 + (yy.to(self._device) - point[1])**2)**0.5
relis, reljs = torch.where(distance < round(r1 / 512 * h))
direction = direction / (torch.linalg.norm(direction) + 1e-7)
gridh = (relis-direction[1]) / (h-1) * 2 - 1
gridw = (reljs-direction[0]) / (w-1) * 2 - 1
gridh = (relis+direction[1]) / (h-1) * 2 - 1
gridw = (reljs+direction[0]) / (w-1) * 2 - 1
grid = torch.stack([gridw,gridh], dim=-1).unsqueeze(0).unsqueeze(0)
target = F.grid_sample(feat_resize.float(), grid, align_corners=True).squeeze(2)
loss_motion += F.l1_loss(feat_resize[:,:,relis,reljs], target.detach())
loss_motion += F.l1_loss(feat_resize[:,:,relis,reljs].detach(), target)

loss = loss_motion
if mask is not None:
Expand Down

0 comments on commit d0422b1

Please sign in to comment.