-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fill arg and _apply_grid_transform improvements #6517
Comments
Since we have another report in #8083, do we want to tackle this? IMO, we should just align the two branches vision/torchvision/transforms/v2/functional/_geometry.py Lines 588 to 594 in f69eee6
with something like bool_mask = mask < 1
float_img[bool_mask] = fill_img.expand_as(float_img)[bool_mask] This removes the blending and in turn the "shadow" for bilinear interpolation. Plus, this is equivalent for nearest interpolation, since the mask in that case only contains |
@pmeier the value 0.9999 for mask was sort of on purpose. In the description example affine rotation by 50 degrees with bilinear mode creates a rotated mask with unique values:
and
|
this hasn't been fixed |
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:
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 hassum(fill) == 0
asgrid_sample
pads with zeros.fill_img
andimg
interpolation may be replaced by directly applying a mask:That would match better PIL Image behaviour.
vision/torchvision/transforms/functional_tensor.py
Lines 567 to 568 in 0d69e35
cc @datumbox
The text was updated successfully, but these errors were encountered: