wip: fix padding issues in augmentation pipeline #1275
Draft
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.
Description
Fixes some unexpected behavior during augmentation.
kornia.This may be a limitation of how
korniaconstructs/chains the transformation matrices for different operations.korniatransforms input boxes/points but it doesn't do any filtering afterwards. If the source image is rotated for example, it will may result in boxes going out of bounds. Currently, we clip to the bounds of the augmented image, but if padding is forced to be the last operation, we should clip to the source image and then pad to the desired size. In the other direction, if the image is cropped, then we want to bound the labels to the transformed image.This PR makes two changes:
PadTooperation, move it to the final step. This ensures that the resulting labels are correct. This is opinionated, but until we figure out a way to solve the label transform problem, it's a safe compromise and should always yield correct labels even if the transform pipeline is specified out of order by mistake.Typical corrected sample:
Related Issue(s)
#1274 - related, but this does not change the behavior of PadTo (unexpected cropping).
AI-Assisted Development
Auto-complete only for updating filter_boxes