Repository navigation
[transforms] Keep at least one pixel per side when RandomResize scales a small image - #2213
Merged
felixdittrich92 merged 1 commit intoNov 2, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2213 +/- ##
==========================================
- Coverage 97.78% 97.78% -0.01%
==========================================
Files 170 170
Lines 10993 10993
==========================================
- Hits 10750 10749 -1
- Misses 243 244 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
RandomResizecomputes the new size withint(size * scale), so a side under 4 pixels becomes 0 with the defaultscale_range=(0.3, 0.9).Resizethen raisesRuntimeError: Input and output sizes should be greater than 0, orZeroDivisionErrorintarget_ratio = self.size[0] / self.size[1]when the width is the one that becomes 0. A 1-pixel high crop fails every time, a 3x40 crop (a dash, a dot) about 5% of the time.Each side is now kept at least at one pixel. Other sizes are resized as before.
Test:
test_random_resize_small_imagewith 1x50, 3x40, 10x3 and 2x2 images, with and withoutpreserve_aspect_ratio. It fails on main