Skip to content
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

allow float fill for integer images in F.pad #7950

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

pmeier
Copy link
Contributor

@pmeier pmeier commented Sep 8, 2023

Fixes #7948

cc @vfdev-5

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 8, 2023

Comment on lines +421 to +422
# turns all warnings into errors for this module
pytestmark = pytest.mark.filterwarnings("error")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure, we never miss a warning coming from the transforms again.

@@ -312,11 +312,12 @@ def adapt_fill(value, *, dtype):
return value

max_value = get_max_value(dtype)
value_type = float if dtype.is_floating_point else int
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we adapt the fill value, we also want to adapt the type. I've checked and this does not hide the errors that we are fixing here.

if isinstance(input, tv_tensors.Mask) and isinstance(value, (tuple, list)):
pytest.skip("F.pad_mask doesn't support non-scalar fill.")

kwargs["fill"] = adapt_fill(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've missed to adapt the value here.

@@ -3478,6 +3487,8 @@ def test_transform_errors(self):
def test_image_correctness(self, padding, padding_mode, fill, fn):
image = make_image(dtype=torch.uint8, device="cpu")

fill = adapt_fill(fill, dtype=torch.uint8)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Philip!

test/test_transforms_v2_refactored.py Outdated Show resolved Hide resolved
@pmeier pmeier merged commit d78b462 into pytorch:main Sep 8, 2023
46 of 62 checks passed
@pmeier pmeier deleted the fill-int-float branch September 8, 2023 11:52
pmeier added a commit to pmeier/vision that referenced this pull request Sep 8, 2023
Conflicts:
	test/test_transforms_v2_refactored.py
facebook-github-bot pushed a commit that referenced this pull request Sep 26, 2023
Reviewed By: matteobettini

Differential Revision: D49600774

fbshipit-source-id: 3671923921f6da913ce94c327e075e4304f2e964
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning for fill stuff
3 participants