docling-project / docling-project/docling
Table Incorrectly Identified as Form Area in Scanned PDF
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
In the attached scanned PDF, the tables on pages 1 and 4 are being tagged as "form" instead of "table", causing their contents to be processed into a "group" object instead of a "table" object in the docling document. I cannot determine any particular reason for this, as page 3 looks very similar to page 1 and page 4 looks similar to page 5. You can see this in the debug postprocessing image for the pages:
...
### Steps to reproduce
Using the attached file, run this:
```
import json
from docling.datamodel.settings import settings
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import (
VlmPipelineOptions,
VlmConvertOptions,
PdfPipelineOptions,
)
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.pipeline.vlm_pipeline import VlmPipeline
settings.debug.visualize_layout = True
settings.debug.visualize_tables = True
settings.debug.visualize_ocr = True
filename = "docling-layout-bug.pdf"
# vlm_options = VlmConvertOptions.from_preset("granite_docling")
# pipeline_options = VlmPipelineOptions(vlm_options=vlm_options)
# pipeline_options = PdfPipelineOptions()
# pipeline_options.do_ocr = True
# pipeline_options.do_table_structure = True
converter = DocumentConverter(
# format_options={
# InputFormat.PDF: PdfFormatOption(
# pipeline_cls=VlmPipeline, pipeline_options=pipeline_options
# )
# }
)
# Convert and export
result = converter.convert(filename)
json.dump(
result.document.export_to_dict(),
open("contents.json", "w", encoding="utf-8"),
indent=2,
)
```
It also happens with the various commented out options enabled. They do not seem to affect the layout detection, just the contents.
...
### Docling version
Docling version: 2.93.0
Docling Core version: 2.74.1
Docling IBM Models version: 3.13.2
Docling Parse version: 5.10.0
Python: cpython-312 (3.12.9)
Platform: macOS-15.7.4-arm64-arm-64bit
...
### Python version
Python 3.12.9
...
[docling-layout-bug.pdf](https://github.com/user-attachments/files/27813251/docling-layout-bug.pdf)
Contributor guide
Assessment
This issue has not been assessed yet.