feat(layout): add opt-out for dropping pictures that coincide with tables (#3922) - #3927
Open
Anai-Guo wants to merge 1 commit into
Open
Conversation
…bles Since 2.103.0 a PICTURE cluster whose bbox nearly coincides with a TABLE cluster is dropped, keeping only the structured TABLE. That is right in the common case, but there is no way to opt out, and dropping the picture also removes the region's rendered crop -- which some pipelines use as a fallback when table extraction is poor. Add `remove_pictures_coinciding_with_tables` to BaseLayoutPostprocessorOptions, defaulting to True so today's behaviour is unchanged. When set to False the coinciding PICTURE is kept alongside the TABLE. Fixes docling-project#3922 Signed-off-by: Tai An <antai12232931@outlook.com>
Contributor
|
✅ DCO Check Passed Thanks @Anai-Guo, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
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.
Fixes #3922
Problem
Since 2.103.0 (#3523, extended by #3536 and #3789)
LayoutPostprocessor._handle_cross_type_overlapsdrops a PICTURE cluster whose bbox nearly coincides with a TABLE cluster (IoU > 0.8), keeping only the structured TABLE.That is the right call in the common case, but there is no way to opt out. Dropping the picture also removes the only signal that there is an image there — including the region's rendered crop. As reported in #3922, some pipelines use that crop as a safety net: when TableFormer extracts a table badly, a vision-model description of the same region recovers the content. With the picture gone, the fallback is gone too.
Change
Add
remove_pictures_coinciding_with_tablestoBaseLayoutPostprocessorOptions, defaulting toTrueso current behaviour is unchanged. When set toFalse, the coinciding PICTURE is kept alongside the TABLE.The option lives on the layout-postprocessor options rather than on
PdfPipelineOptions(as sketched in the issue), because that is where the deduplication actually runs and where the sibling toggles (keep_empty_clusters,skip_cell_assignment,create_orphan_clusters) already live.The table itself is untouched — this only controls whether the duplicate PICTURE survives.
Tests
tests/test_layout_postprocessor.pygainstest_cross_type_overlaps_keeps_coinciding_picture_when_opted_out, asserting both clusters survive when the option is disabled. The three existing cross-type tests build a half-initialized postprocessor viaobject.__new__, so they now also setprocessor.options; their assertions are unchanged.Verified locally against the postprocessor as it stands on
main(byte-identical to the file in this PR's base):The ML-backed integration test
tests/test_layout_picture_table_overlap.pykeeps passing unchanged, since the default staysTrue.ruff0.15.12 (check+format, repopyproject.toml) reports nothing new relative tomainon the three touched files.🤖 Generated with Claude Code