Fix incorrect normalization axis in v2.ElasticTransform (Fixes #9299)#9300
Fix incorrect normalization axis in v2.ElasticTransform (Fixes #9299)#9300NicolasHug merged 9 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9300
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @ericjaebeom! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@ericjaebeom Thanks a lot for the issue and PR! I also did some experiments to validate this PR is correct. I also find that for v1, we have the same issue. Could you please also fix that in v1 in this PR? By the way, could you please write a non-regression test on v2 for this? You can add the test into the class "TestElastic" in the file "test_transforms_v2.py". Feel free to let us know if you have any questions. |
…tion in v2 ElasticTransform
…sion into fix/elastic-transform-bug
Changesv1 v2 On regression testingI explored adding a non-regression test as requested, but found it difficult to design a meaningful deterministic test for this behavior. The test would need to verify that
# Mirrors the implementation exactly
torch.manual_seed(0)
rand_dx = torch.rand(1, 1, height, width) * 2 - 1
rand_dy = torch.rand(1, 1, height, width) * 2 - 1
expected_dx = rand_dx * alpha[0] / width
expected_dy = rand_dy * alpha[1] / height
# Hypothesis test
ratio = torch.std(dy) / torch.std(dx)
assert ratio > 5 # Threshold based on width/height ratio
# Alternatively, validate the bound of dy, dxThe root cause of this bug was conflating I'd appreciate your thoughts on whether a regression test is still warranted given these trade-offs. |
|
Thanks a lot for investigating the non-regression tests. In this case, we think the non-regression tests will not be needed. Thank you very much for your contributions! |
|
Thanks for the review and the guidance! |
NicolasHug
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR and for the fix @ericjaebeom !
Thanks @zy1git for the review!
|
Hey @NicolasHug! You merged this PR, but no labels were added. |
This PR fixes a bug where horizontal/vertical displacements were normalized by the wrong spatial dimension (swapped height/width). Validated with reproduction script in Issue #9299. Fixes #9299
cc @vfdev-5