Fix #1274: Rename and fix PadIfNeeded to only pad (no crop)#1296
Fix #1274: Rename and fix PadIfNeeded to only pad (no crop)#1296abhayrajjais01 wants to merge 5 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.34% 87.41% +0.07%
==========================================
Files 24 24
Lines 2978 2996 +18
==========================================
+ Hits 2601 2619 +18
Misses 377 377
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
|
@henrykironde can you please review and tell me if changes needed?? |
|
@abhayrajjais01 - thanks for the contribution, but per our developer guide we want you to engage with us on an issue (and actually hear back from someone; ideally being assigned to the issue) before submitting PRs. @jveitchmichaelis has an opened a WIP PR on this a while ago. You can ask in the original issue if he'd like some help on it and if he says yes then you can proceed. |
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