remove clamp_keypoints from transforms#9236
Merged
AntoineSimoulin merged 3 commits intopytorch:mainfrom Oct 8, 2025
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9236
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 859622b with merge base 7a13ad0 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
NicolasHug
approved these changes
Oct 8, 2025
Member
NicolasHug
left a comment
There was a problem hiding this comment.
Thank you @AntoineSimoulin !
|
Hey @AntoineSimoulin! You merged this PR, but no labels were added. |
AntoineSimoulin
added a commit
to AntoineSimoulin/vision
that referenced
this pull request
Oct 9, 2025
Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This PR proposes an alternative to #9234. We disable the clamping for
KeyPointsafter the following transformationsvertical_flip_keypoints,horizontal_flip_keypoints,_affine_keypoints_with_expand,pad_keypoints,crop_keypoints,perspective_keypoints, andelastic_keypoints. We are fixing this to avoid the issue observed in #9223, where clamping modifies the position ofKeyPointsand create a misalignment with the actual locations in the transformed image. This PR will need to be supplemented with #9235 to implement a class similar toSanitizeBoundingBoxestransform to remove non validKeyPoints, e.g. outside of the image canvas.Implementation details
In the current proposition, we simply do not apply the
clamp_keypointsby default after any transform. ForKeyPoints, the clamping must therefore be explicitly set with theClampKeyPointstransform.Illustration of the changes
Without explicit clamping
With explicit clamping (default before)
Testing
Please run the following unit tests