Skip to content

Conversation

@raimbekovm
Copy link
Contributor

@raimbekovm raimbekovm commented Jan 8, 2026

Fixes #9299

The displacement normalization was swapped - dx was divided by height and dy by width, but it should be the other way around since grid coordinates in _create_identity_grid are normalized by their respective dimensions (x by width, y by height).

Tested on a 100x200 image with alpha=[50, 50]:

Current:  dx=1.3px, dy=0.3px (ratio 4.0)
Fixed:    dx=0.7px, dy=0.7px (ratio 1.0)

Equal alpha values should produce ~equal displacement in both directions. The current code gives 4x stronger horizontal displacement on a 2:1 image.

Square images are unaffected (both implementations identical), which explains why this wasn't caught before.

The failing CI is the v1 compatibility check - v1 has the same bug. Happy to fix v1 as well or skip the check for non-square images, whichever you prefer.

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 8, 2026

🔗 Helpful Links

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

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

❌ 8 New Failures

As of commit 512f717 with merge base 1e53952 (image):

NEW FAILURES - The following jobs have failed:

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

@meta-cla meta-cla bot added the cla signed label Jan 8, 2026
@raimbekovm
Copy link
Contributor Author

The failing tests are v1 compatibility checks for non-square images. v1 has the same bug so the outputs now differ.

Should I fix v1 as well or skip the v1 check for non-square images?

@zy1git
Copy link
Contributor

zy1git commented Jan 22, 2026

@raimbekovm Thank you so much for this PR! And really appreciate your investigations on the test errors!

Since author of the original issue #9299 also submit a PR #9300 , we might just follow up on that PR. However, I will discuss with my tech lead whether it would be good for you two to work together on that PR.

I’ll keep you updated once I have more clarity. Thanks again for your contributions!

@raimbekovm
Copy link
Contributor Author

No worries, glad I could help with the investigation at least!

@NicolasHug
Copy link
Member

Looks like OP followed-up on #9300 already, so I think we'll just go ahead with that one.

@raimbekovm thank you so much for your help with this PR and with the other ones you opened! We really appreciate your help 🙏

@NicolasHug NicolasHug closed this Jan 22, 2026
@raimbekovm
Copy link
Contributor Author

Happy to help! Feel free to ping me if you need anything.

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.

v2.ElasticTransform applies incorrect vertical/horizontal normalization on displacement vectors

3 participants