sniklaus / pytorch-pwc

a reimplementation of PWC-Net in PyTorch that matches the official Caffe version
GNU General Public License v3.0
608 stars 122 forks source link

align_corners function parameter is inconsistent between grid_sample and interpolate method #33

Closed TechieBoy closed 4 years ago

TechieBoy commented 4 years ago

In the current code, grid_sample() is not passed the align_corners parameter so it is set to True as described here https://github.com/sniklaus/pytorch-pwc/blob/1a5f1969c51a865cd184450f76251ba1f77b07e9/run.py#L61

However, interpolate() has align_corners set to False. https://github.com/sniklaus/pytorch-pwc/blob/1a5f1969c51a865cd184450f76251ba1f77b07e9/run.py#L299

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.

sniklaus commented 4 years ago

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: https://github.com/pytorch/pytorch/pull/23923