sniklaus/pytorch-pwc

align_corners function parameter is inconsistent between grid_sample and interpolate method

TechieBoy opened this issue · 1 comments

In the current code, grid_sample() is not passed the align_corners parameter so it is set to True as described here

tensorOutput = torch.nn.functional.grid_sample(input=tensorInput, grid=(Backward_tensorGrid[str(tensorFlow.size())] + tensorFlow).permute(0, 2, 3, 1), mode='bilinear', padding_mode='zeros')

However, interpolate() has align_corners set to False.

tensorFlow = 20.0 * torch.nn.functional.interpolate(input=moduleNetwork(tensorPreprocessedFirst, tensorPreprocessedSecond), size=(intHeight, intWidth), mode='bilinear', align_corners=False)

From the pytorch docs:
The align_corners option parallels the align_corners option in interpolate(), and so whichever option is used here should also be used there to resize the input image before grid sampling.

Is this intended? If not, then align_corners=False needs to be passed in to the grid_sample() function.

Thank you for bringing this to my attention, I changed the grid sampler to align_corners=True since this is what the reference implementation does (and the provided models were trained with this configuration). I appreciate that you bring it up since the default changed to align_corners=False with the newest PyTorch release, which breaks backwards compatibility: pytorch/pytorch#23923