Skip to content

fix resize_mask ignoring NEAREST_EXACT interpolation#9384

Open
Mr-Neutr0n wants to merge 1 commit intopytorch:mainfrom
Mr-Neutr0n:fix-mask-nearest-exact-interpolation
Open

fix resize_mask ignoring NEAREST_EXACT interpolation#9384
Mr-Neutr0n wants to merge 1 commit intopytorch:mainfrom
Mr-Neutr0n:fix-mask-nearest-exact-interpolation

Conversation

@Mr-Neutr0n
Copy link

Fixes #9188

resize_mask() was hardcoding InterpolationMode.NEAREST and ignoring the user-specified interpolation mode entirely. This meant NEAREST_EXACT (which is the more correct interpolation — matching PIL and scikit-image behavior) got silently dropped when resizing a tv_tensors.Mask.

The fix adds an interpolation parameter to resize_mask() and passes it through from the dispatch function. Only NEAREST and NEAREST_EXACT are accepted — anything else (bilinear, bicubic, etc.) falls back to NEAREST since those don't make sense for masks.

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 15, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9384

Note: Links to docs will display an error until the docs builds have been completed.

❌ 6 New Failures

As of commit 177f66e with merge base 0f6d91d (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@zy1git
Copy link
Contributor

zy1git commented Feb 20, 2026

@Mr-Neutr0n Hi,

Thanks a lot for creating the PR. I am reviewing it. At the same time, could you please take a look at the test errors and address those?

@zy1git
Copy link
Contributor

zy1git commented Feb 23, 2026

I took a look at the test errors and wanted to share a few observations:

a, the signature order does not match F.resize: resize_mask(mask, size, max_size, interpolation) should be resize_mask(mask, size, interpolation, max_size).
b, set literal {NEAREST, NEAREST_EXACT} is not compatible with TorchScript.
c, The default value (NEAREST) differs from F.resize (BILINEAR) in the test file, which causes test_functional_signature to fail.

If you have any questions while addressing the CI test failures, please feel free to reach out.

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.

InterpolationMode.NEAREST_EXACT and InterpolationMode.NEAREST are the same for tv_tensors.Mask

2 participants