fix(geometry): apply inclusive last-index per box in extract_crops#2071
Open
devteamaegis wants to merge 1 commit into
Open
fix(geometry): apply inclusive last-index per box in extract_crops#2071devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
extract_crops incremented the wrong axis (`_boxes[2:] += 1` shifted every box from index 2 onward by +1 in all four coordinates), instead of adding the inclusive +1 to the xmax/ymax columns of each box (`_boxes[:, 2:] += 1`). This made crops positionally inconsistent: identical boxes at batch index >=2 sampled a region shifted by one pixel in x and y.
Collaborator
|
Hi @devteamaegis 👋 Thanks for the fix 👍 |
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's broken
extract_cropsis meant to add an inclusive+1to each box'sxmax/ymax("Add last index"), but the increment lands on the wrong axis:_boxes[2:] += 1adds 1 to all four coordinates of every box from batch index 2 onward, instead of adding 1 to the xmax/ymax columns of every box. So with 3+ boxes, every crop from index 2 on is cut from a region shifted one pixel in both x and y. The detection→recognition pipeline calls this with many boxes per page, so crops 3+ are silently misaligned.Why it happens
_boxes[2:] += 1indexes the box axis; it should be_boxes[:, 2:] += 1(the coordinate columns).Fix
Change
_boxes[2:] += 1to_boxes[:, 2:] += 1.Test
Added a case to
test_extract_cropsusing a vertical-gradient image: three identical boxes must yield identical crops regardless of batch position. Fails before, passes after.