Fix #1274: Rename and fix PadIfNeeded to only pad (no crop)#1296
Open
abhayrajjais01 wants to merge 4 commits intoweecology:mainfrom
Open
Fix #1274: Rename and fix PadIfNeeded to only pad (no crop)#1296abhayrajjais01 wants to merge 4 commits intoweecology:mainfrom
abhayrajjais01 wants to merge 4 commits intoweecology:mainfrom
Conversation
- Distribute padding evenly on all sides (left/right, top/bottom) - Keeps image centered to preserve spatial alignment - Addresses feedback from @Prathamesh8989 in PR weecology#1289
42ee699 to
c0f0e17
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1296 +/- ##
==========================================
- Coverage 87.89% 87.43% -0.46%
==========================================
Files 20 21 +1
Lines 2776 2826 +50
==========================================
+ Hits 2440 2471 +31
- Misses 336 355 +19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Changed default p from 0.5 to 1.0 to ensure padding always applies - Fixes CI test failures where augmentation was randomly skipping - All 28 augmentation tests now pass consistently
ae5f444 to
7195348
Compare
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.
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 codebase