Fix #1274: Rename and fix PadIfNeeded to only pad (no crop) #1296
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.
Summary
This PR fixes Issue #1274 where
PadIfNeededwas incorrectly cropping images larger than the target size because it was aliased directly toKornia.PadTo.Changes
PadIfNeededClass: Implemented a customPadIfNeededaugmentation (inheriting fromGeometricAugmentationBase2D) that:PadTo: Added a new key"PadTo"to_SUPPORTED_TRANSFORMSthat maps to the originalKornia.PadTobehavior. This preserves backward compatibility for users who relied on the cropping behavior.test_pad_if_neededintests/test_augmentations.pyto verify:PadTostill works as expected (legacy behavior).Verification
Ran tests via Docker:
docker compose run --rm deepforest pytest tests/test_augmentations.pyResult: All 28 tests passed.
I have taken help of ai to understand the issue.