Repository navigation
fix: deduplicate nested layout regions after disjoint candidates - #536
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
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.
Layout deduplication stops when the largest candidate contains no later regions. A smaller candidate can still contain duplicates, so a disjoint larger region causes those nested duplicates to survive. This also affects class-specific cleanup.
Remove the early exit in both cleanup loops so remaining candidates are examined. Add regression coverage for both helpers and the detection model's deduplication entry point, checking coordinates, text, and class IDs. Update the dense reference and allocation assertions to account for visiting all remaining candidates. Bump the version and changelog as required by the contribution checklist.
For example, boxes
[0, 0, 100, 100],[110, 0, 130, 20], and[111, 1, 112, 2]form one padded detection group. Cleanup now keeps the first two and removes the nested third box.Removing the early exit means N disjoint regions in one group require N−1 bounded comparisons instead of one (measured locally with 10,000 disjoint regions: about 3 ms → 0.8 s); memory remains linear.
Testing and validation
test_detection_model_pipeline_preserves_connected_regions_and_routing.PYTHONPATH=. python -m pytest -q test_unstructured_inference/inference/test_layout_cleanup_nested.py test_unstructured_inference/inference/test_layout_cleanup_memory.py test_unstructured_inference/inference/test_layout_element.py test_unstructured_inference/test_elements.py.AI assistance was used to prepare this change and its tests.