Skip to content

fix(layout): remove wrapper picture proposals - #4149

Open
cau-git wants to merge 3 commits into
mainfrom
cau/pr-4047-wrapper-filter
Open

fix(layout): remove wrapper picture proposals#4149
cau-git wants to merge 3 commits into
mainfrom
cau/pr-4047-wrapper-filter

Conversation

@cau-git

@cau-git cau-git commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove PICTURE proposals that wrap every surviving model-detected layout element when the page area outside the proposal is a single background color.
  • Exclude synthesized orphan text clusters from the evidence used to remove a picture.
  • Preserve lone or empty full-page pictures, pictures with non-uniform surroundings, and pictures when any detected element lies outside.

Difference from #4047

This targets the same failure as #4047: landscape slide-like content embedded in a portrait PDF can be classified as one large picture, hiding machine-readable text and causing picture description to receive the whole slide.

#4047 computes a union from regular and special clusters and removes a picture when its bounding box equals that union. Because the candidate picture participates in the union, any picture containing the remaining clusters defines the union itself. The decision therefore reduces to containment and does not inspect the surrounding page raster.

This PR ports the fix onto current main and requires three independent signals:

  1. Every other surviving model detection is fully inside the candidate picture.
  2. At least one geometrically distinct inner element is a real layout-model detection; raw text cells and synthesized orphan clusters do not count.
  3. All pixels outside the candidate share one RGB background color, ignoring a one-pixel rasterization seam.

A nested picture is deliberately not required, so text-only slide frames are handled as well.

Result

On the reported page28.pdf, current main produces one outer picture containing all eight text items, leaving Markdown with only an image placeholder. This change exposes the eight native text items and retains the two internal picture proposals, achieving the same user-visible goal as #4047 with narrower removal conditions.

Validation

  • 28 passed in tests/test_layout_postprocessor.py
  • make validate
  • CPU-only conversion of the reported PDF with DOCLING_DEVICE=cpu, --device cpu, and --no-ocr

Related: #4047

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @cau-git, all your commits are properly signed off. 🎉

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/utils/layout_postprocessor.py 83.67% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
@cau-git

cau-git commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

@phact could you please test this PR with a few more input samples? Thanks.

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
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.

1 participant