Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/fix ocr region to elements bug #3891

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Conversation

badGarnet
Copy link
Collaborator

@badGarnet badGarnet commented Jan 29, 2025

This PR fixes a bug in build_layout_elements_from_ocr_regions where texts are joint in incorrect orders.

The bug is due to incorrect masking of the ocr_regions after some are already selected as one of the final groups. The fix uses simpler method to mask the indices by simply use the same indices that adds the regions to the final groups to mask them so they are not considered again.

Testing

This PR adds a unit test specifically aimed for this bug. Without the fix the test would fail.
Additionally any PDF files with repeated texts has a potential to trigger this bug. e.g., create a simple pdf use the test text

"LayoutParser: \n\nA Unified Toolkit for Deep Learning Based Document Image\n\nLayoutParser for Deep Learning"

and partition with ocr_only mode on main branch would hit this bug and output text where position of the second "LayoutParser" is incorrect.

[
    'LayoutParser:', 
    'A Unified Toolkit for Deep Learning Based Document Image',
    'for Deep Learning LayoutParser',
]

@badGarnet badGarnet marked this pull request as ready for review January 29, 2025 01:08
@badGarnet badGarnet added this pull request to the merge queue Jan 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 29, 2025
@badGarnet badGarnet added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit a9ff1e7 Jan 29, 2025
41 checks passed
@badGarnet badGarnet deleted the fix/fix-ocr-region-to-elements-bug branch January 29, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants