Open
Description
Few years ago we introduced non-const fill value handling in _apply_grid_transform
using mask approach:
vision/torchvision/transforms/functional_tensor.py
Lines 550 to 568 in 0d69e35
There are few minor problems with this approach:
- if we pass
fill = [0.0, ]
, we would expect to have a similar result asfill=None
. This is not exactly true for bilinear interpolation mode where we do linear interpolation:
vision/torchvision/transforms/functional_tensor.py
Lines 567 to 568 in 0d69e35
Most probably, we would like to skip fill_img
creation for all fill values that has sum(fill) == 0
as grid_sample
pads with zeros.
- if fill is not None:
+ if fill is not None and sum(fill) > 0:
- Linear
fill_img
andimg
interpolation may be replaced by directly applying a mask:
mask = mask < 0.9999
img[mask] = fill_img[mask]
That would match better PIL Image behaviour.
vision/torchvision/transforms/functional_tensor.py
Lines 567 to 568 in 0d69e35
cc @datumbox
Activity