Fix zero-padding edge case in tile stitching#60
Open
Dartayous wants to merge 1 commit into
Open
Conversation
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.
What is the purpose of this PR?
This PR fixes a tile-stitching edge case related to issue #59.
When bottom or right padding is
0, the current_stitch_tiles()slicing logic can collapse the stitched output to an empty spatial dimension because Python evaluates-0as0.Closes #59
How did you implement your changes?
Updated
Nimbus._stitch_tiles()insrc/nimbus_inference/nimbus.py.The previous implementation used:
When
padding[1] == 0orpadding[3] == 0, this becomes astart:0slice and can produce an output shape like(1, 1, 0, 0).The fix explicitly uses
Nonefor zero end-padding:I also added a regression test,
test_stitch_tiles_handles_zero_end_padding, which verifies that zero bottom/right padding preserves the expected stitched output shape.Validation:
Remaining issues
None from my testing. I would appreciate maintainer feedback on whether this is the preferred place to handle the zero-padding crop edge case.