mmtracking
mmtracking copied to clipboard
Abount flow grid in mmtrack.core.motion.flow.py line 27,29
I think it should be: grid[:, 0] = grid[:, 0] / (W-1) * 2 - 1 grid[:, 1] = grid[:, 1] / (H-1) * 2 - 1
demo test: import torch import torch.nn.functional as F
x = torch.arange(1,5, dtype=torch.float32)
x = x.view(1,1,2,2)
print('input', x)
h, w = x.shape[-2:]
h_grid, w_grid = torch.meshgrid(torch.arange(h), torch.arange(w))
grid = torch.cat((w_grid[None, None, ...], h_grid[None, None, ...]), dim=1)
grid[:, 0] = grid[:, 0] / (w-1) * 2 - 1
grid[:, 1] = grid[:, 1] / (h-1) * 2 - 1
grid = grid.permute(0, 2, 3, 1).float()
print('grid', grid)
x_warp = F.grid_sample(x, grid, padding_mode='border', align_corners=True)
print('x_warp', x_warp)
What you said is right in the case of 'align_corners=True'. Could you please create a PR to fix it?