docling-pp-doc-layout 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. docling_pp_doc_layout-0.1.0/.agent/rules/python.mdc +17 -0
  2. docling_pp_doc_layout-0.1.0/.github/workflows/main.yml +62 -0
  3. docling_pp_doc_layout-0.1.0/.github/workflows/publish.yml +45 -0
  4. docling_pp_doc_layout-0.1.0/.gitignore +56 -0
  5. docling_pp_doc_layout-0.1.0/.pre-commit-config.yaml +21 -0
  6. docling_pp_doc_layout-0.1.0/.python-version +1 -0
  7. docling_pp_doc_layout-0.1.0/CLAUDE.md +55 -0
  8. docling_pp_doc_layout-0.1.0/LICENSE +21 -0
  9. docling_pp_doc_layout-0.1.0/Makefile +56 -0
  10. docling_pp_doc_layout-0.1.0/PKG-INFO +154 -0
  11. docling_pp_doc_layout-0.1.0/README.md +131 -0
  12. docling_pp_doc_layout-0.1.0/codecov.yml +15 -0
  13. docling_pp_doc_layout-0.1.0/pyproject.toml +155 -0
  14. docling_pp_doc_layout-0.1.0/renovate.json +12 -0
  15. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/__init__.py +3 -0
  16. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/label_mapping.py +34 -0
  17. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/model.py +225 -0
  18. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/options.py +46 -0
  19. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/plugin.py +12 -0
  20. docling_pp_doc_layout-0.1.0/src/docling_pp_doc_layout/py.typed +0 -0
  21. docling_pp_doc_layout-0.1.0/tests/__init__.py +0 -0
  22. docling_pp_doc_layout-0.1.0/tests/conftest.py +36 -0
  23. docling_pp_doc_layout-0.1.0/tests/test_end_to_end.py +440 -0
  24. docling_pp_doc_layout-0.1.0/tests/test_label_mapping.py +136 -0
  25. docling_pp_doc_layout-0.1.0/tests/test_model.py +297 -0
  26. docling_pp_doc_layout-0.1.0/tests/test_options.py +104 -0
  27. docling_pp_doc_layout-0.1.0/tests/test_plugin.py +29 -0
  28. docling_pp_doc_layout-0.1.0/tests/test_predict_layout.py +742 -0
  29. docling_pp_doc_layout-0.1.0/uv.lock +2454 -0
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Python
3
+ globs: **/*.py
4
+ alwaysApply: false
5
+ ---
6
+
7
+ You have access to context7 to fetch up to date documentation on libraries and frameworks.
8
+
9
+
10
+ Execute python code, tests, ruff or linter:
11
+ - Always use uv or make to execute commands.
12
+ - To run python files: `uv run script.py`
13
+ - To run tests: `make test`
14
+ - To run pre-commit: `make check`
15
+
16
+ Development Guidelines:
17
+ Check the development guidelines here: https://dcc-bs.github.io/documentation/coding/python.html
@@ -0,0 +1,62 @@
1
+ name: Main
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ # ---------------------------------------------------------------------------
13
+ # Quality checks via DCC-BS reusable workflow (ruff lint + format + ty)
14
+ # ---------------------------------------------------------------------------
15
+ quality:
16
+ uses: DCC-BS/ci-workflows/.github/workflows/python-backend-ci.yml@v8
17
+ with:
18
+ python_versions: '["3.13"]'
19
+ quality_python_version: "3.13"
20
+ check_command: "make check"
21
+
22
+ # ---------------------------------------------------------------------------
23
+ # Tests + coverage
24
+ # ---------------------------------------------------------------------------
25
+ tests:
26
+ name: Tests (Python ${{ matrix.python-version }})
27
+ runs-on: ubuntu-latest
28
+ needs: [quality]
29
+ strategy:
30
+ fail-fast: false
31
+ matrix:
32
+ python-version: ["3.13"]
33
+
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+
37
+ - name: Install uv
38
+ uses: astral-sh/setup-uv@v5
39
+ with:
40
+ enable-cache: true
41
+ cache-dependency-glob: "uv.lock"
42
+
43
+ - name: Set up Python ${{ matrix.python-version }}
44
+ run: uv python install ${{ matrix.python-version }}
45
+
46
+ - name: Install dependencies
47
+ run: uv sync --all-extras --dev
48
+
49
+ - name: Run tests with coverage
50
+ run: uv run pytest --cov --cov-report=xml --junitxml=junit.xml
51
+
52
+ - name: Upload coverage to Codecov
53
+ uses: codecov/codecov-action@v5
54
+ with:
55
+ token: ${{ secrets.CODECOV_TOKEN }}
56
+ files: ./coverage.xml
57
+ - name: Upload test results to Codecov
58
+ if: ${{ !cancelled() }}
59
+ uses: codecov/test-results-action@v1
60
+ with:
61
+ token: ${{ secrets.CODECOV_TOKEN }}
62
+ files: ./junit.xml
@@ -0,0 +1,45 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ id-token: write # required for PyPI trusted publishing
8
+ contents: write # required to push git tags
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+ with:
22
+ enable-cache: true
23
+
24
+ - name: Set up Python
25
+ run: uv python install 3.13
26
+
27
+ - name: Create and push git tag
28
+ run: |
29
+ VERSION=$(uv version --short)
30
+ TAG="v${VERSION}"
31
+ git config --global user.name "github-actions[bot]"
32
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
33
+ if git rev-parse "$TAG" >/dev/null 2>&1 || git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
34
+ echo "Tag $TAG already exists – skipping"
35
+ else
36
+ git tag "$TAG"
37
+ git push origin "$TAG"
38
+ echo "Created and pushed tag $TAG"
39
+ fi
40
+
41
+ - name: Build package
42
+ run: uv build
43
+
44
+ - name: Publish to PyPI
45
+ run: uv publish
@@ -0,0 +1,56 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .eggs/
11
+ .installed.cfg
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ wheels/
18
+ share/python-wheels/
19
+ MANIFEST
20
+
21
+ # Virtual environments
22
+ .venv/
23
+ env/
24
+ venv/
25
+ ENV/
26
+
27
+ # Testing & coverage
28
+ .pytest_cache/
29
+ .coverage
30
+ coverage.xml
31
+ htmlcov/
32
+ .tox/
33
+
34
+ # Type checkers
35
+ .mypy_cache/
36
+ .ruff_cache/
37
+ .ty_cache/
38
+
39
+ # IDEs
40
+ .idea/
41
+ .vscode/
42
+ *.swp
43
+ *.swo
44
+ *~
45
+
46
+ # OS
47
+ .DS_Store
48
+ Thumbs.db
49
+
50
+ # Distribution
51
+ *.tar.gz
52
+ *.whl
53
+
54
+ # Environment variables
55
+ .env
56
+ .env.local
@@ -0,0 +1,21 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: "v5.0.0"
4
+ hooks:
5
+ - id: check-case-conflict
6
+ - id: check-merge-conflict
7
+ - id: check-toml
8
+ - id: check-yaml
9
+ - id: check-json
10
+ - id: end-of-file-fixer
11
+ - id: trailing-whitespace
12
+ - id: detect-private-key
13
+
14
+ - repo: https://github.com/astral-sh/ruff-pre-commit
15
+ rev: "v0.9.9"
16
+ hooks:
17
+ - id: ruff
18
+ args: [--fix, --exit-non-zero-on-fix]
19
+ types_or: [python, pyi]
20
+ - id: ruff-format
21
+ types_or: [python, pyi]
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,55 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `docling-pp-doc-layout` is a Docling plugin that integrates PaddlePaddle's PP-DocLayout-V3 model for document layout detection. It detects layout elements (text, tables, figures, headers, etc.) in page images and feeds predictions back into Docling's standard pipeline.
8
+
9
+ ## Commands
10
+
11
+ This project uses `uv` as the package manager and `make` to orchestrate common tasks.
12
+
13
+ ```bash
14
+ make install # Install dependencies + pre-commit hooks
15
+ make check # Run all quality checks (lint, format, type-check)
16
+ make lint # Run ruff linter with auto-fix
17
+ make format # Run ruff formatter
18
+ make type-check # Run ty type checker (src/ only)
19
+ make test # Run pytest with terminal coverage report
20
+ make test-xml # Run pytest and produce XML coverage report
21
+ make build # Build distribution packages
22
+ make publish # Publish to PyPI
23
+ ```
24
+
25
+ To run a single test file or test function:
26
+ ```bash
27
+ uv run pytest tests/test_model.py
28
+ uv run pytest tests/test_model.py::test_function_name
29
+ ```
30
+
31
+ ## Architecture
32
+
33
+ The plugin has four core modules under `src/docling_pp_doc_layout/`:
34
+
35
+ - **`plugin.py`** — Entry point. Exposes `layout_engines()` which returns a dict mapping the engine name to `PPDocLayoutV3Model`. Docling discovers plugins via this function.
36
+
37
+ - **`options.py`** — `PPDocLayoutV3Options` (Pydantic model). Configures the model name, confidence threshold (0.0–1.0, default 0.5), and inherits cluster options from Docling. `kind = "ppdoclayout-v3"` identifies this engine type.
38
+
39
+ - **`model.py`** — `PPDocLayoutV3Model`, the core detection class. Inherits from `BaseLayoutModel`. Key flow: `predict_layout()` extracts PIL images from pages → `_run_inference()` runs HuggingFace transformers batch inference → maps raw labels via `label_mapping.py` → applies `LayoutPostprocessor` → returns `LayoutPrediction` objects to Docling.
40
+
41
+ - **`label_mapping.py`** — Maps 21 raw PP-DocLayout-V3 class names to `DocItemLabel` values. **Critical constraint:** every label mapped here must exist in `LayoutPostprocessor.CONFIDENCE_THRESHOLDS`. The test suite enforces this.
42
+
43
+ ## Testing Notes
44
+
45
+ - `tests/conftest.py` mocks the `transformers` module when it is not installed, enabling pure-logic unit tests without GPU/model access.
46
+ - The `transformers_available` fixture skips tests that require actual model inference.
47
+ - 80% coverage minimum is enforced; CI reports to Codecov.
48
+
49
+ ## Code Style
50
+
51
+ - Line length: 120 characters
52
+ - String quotes: double
53
+ - Docstring convention: Google style
54
+ - Type checking: `ty` (not mypy)
55
+ - Ruff enforces a large ruleset (ANN, I, C90, BLE, TRY, S, SIM, PT, and more) — run `make check` before committing.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Data Competence Center Basel-Stadt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,56 @@
1
+ .DEFAULT_GOAL := help
2
+
3
+ .PHONY: help install check lint format type-check test test-xml build clean-build publish
4
+
5
+ help: ## Display available commands
6
+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
7
+ /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
8
+
9
+ # ---------------------------------------------------------------------------
10
+ # Setup
11
+ # ---------------------------------------------------------------------------
12
+
13
+ install: ## Install dependencies and pre-commit hooks
14
+ uv sync --all-extras --dev
15
+ uv run pre-commit install
16
+
17
+ # ---------------------------------------------------------------------------
18
+ # Quality checks
19
+ # ---------------------------------------------------------------------------
20
+
21
+ lint: ## Run ruff linter (with auto-fix)
22
+ uv run ruff check . --fix
23
+
24
+ format: ## Run ruff formatter
25
+ uv run ruff format .
26
+
27
+ type-check: ## Run ty type checker
28
+ uv run ty check src/
29
+
30
+ check: ## Run all quality checks (lint, format check, type check)
31
+ uv run ruff check .
32
+ uv run ruff format --check .
33
+ uv run ty check src/
34
+
35
+ # ---------------------------------------------------------------------------
36
+ # Tests
37
+ # ---------------------------------------------------------------------------
38
+
39
+ test: ## Run tests with terminal coverage report
40
+ uv run pytest
41
+
42
+ test-xml: ## Run tests and produce XML coverage report only
43
+ uv run pytest --cov-report=xml --cov-report=
44
+
45
+ # ---------------------------------------------------------------------------
46
+ # Build & publish
47
+ # ---------------------------------------------------------------------------
48
+
49
+ build: clean-build ## Build distribution packages
50
+ uv build
51
+
52
+ clean-build: ## Remove build artefacts
53
+ rm -rf dist/ build/ *.egg-info
54
+
55
+ publish: build ## Publish package to PyPI
56
+ uv publish
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: docling-pp-doc-layout
3
+ Version: 0.1.0
4
+ Summary: A Docling plugin for PaddlePaddle PP-DocLayout-V3 model document layout detection.
5
+ Project-URL: Homepage, https://github.com/DCC-BS/docling-pp-doc-layout
6
+ Project-URL: Repository, https://github.com/DCC-BS/docling-pp-doc-layout
7
+ Project-URL: Issues, https://github.com/DCC-BS/docling-pp-doc-layout/issues
8
+ Project-URL: Changelog, https://github.com/DCC-BS/docling-pp-doc-layout/releases
9
+ Author-email: Yanick Schraner <yanick.schraner@bs.ch>, Tobias Bollinger <tobias.bollinger@bs.ch>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.13
19
+ Requires-Dist: docling>=2.73
20
+ Requires-Dist: torch
21
+ Requires-Dist: transformers>=5.1.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # docling-pp-doc-layout
25
+
26
+ A [Docling](https://github.com/docling-project/docling) plugin that provides document layout detection using the PaddlePaddle PP-DocLayout-V3 model.
27
+
28
+ This plugin seamlessly integrates with Docling's standard pipeline to replace the default layout models with [PP-DocLayout-V3](https://huggingface.co/PaddlePaddle/PP-DocLayoutV3), enabling high-accuracy, instance segmentation-based layout analysis with polygon bounding box support, properly processed in optimized batches for enterprise scalability.
29
+
30
+ ---
31
+
32
+ <p align="center">
33
+ <a href="https://github.com/DCC-BS/docling-pp-doc-layout">GitHub</a>
34
+ &nbsp;|&nbsp;
35
+ <a href="https://pypi.org/project/docling-pp-doc-layout/">PyPI</a>
36
+ </p>
37
+
38
+ ---
39
+
40
+ [![PyPI version](https://img.shields.io/pypi/v/docling-pp-doc-layout.svg)](https://pypi.org/project/docling-pp-doc-layout/)
41
+ [![Python versions](https://img.shields.io/pypi/pyversions/docling-pp-doc-layout.svg)](https://pypi.org/project/docling-pp-doc-layout/)
42
+ [![License](https://img.shields.io/github/license/DCC-BS/docling-pp-doc-layout)](https://github.com/DCC-BS/docling-pp-doc-layout/blob/main/LICENSE)
43
+ [![CI](https://github.com/DCC-BS/docling-pp-doc-layout/actions/workflows/main.yml/badge.svg)](https://github.com/DCC-BS/docling-pp-doc-layout/actions/workflows/main.yml)
44
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
45
+ [![Coverage](https://codecov.io/gh/DCC-BS/docling-pp-doc-layout/graph/badge.svg)](https://codecov.io/gh/DCC-BS/docling-pp-doc-layout)
46
+
47
+
48
+ ## Overview
49
+
50
+ `docling-pp-doc-layout` provides the `PPDocLayoutV3Model` layout engine for Docling. It automatically registers itself into Docling's plugin system upon installation. When configured in a Docling `DocumentConverter`, it intercepts page images, batches them, and infers document structural elements (text, tables, figures, headers, etc.) using HuggingFace's transformers library.
51
+
52
+ Key Features:
53
+ - **High Accuracy Layout Parsing**: Uses the RT-DETR instance segmentation framework.
54
+ - **Polygon Conversion**: Gracefully flattens complex polygon masks to Docling-compatible bounding boxes.
55
+ - **Enterprise Scalability**: Configurable batch sizing avoids out-of-memory (OOM) errors on large documents.
56
+
57
+ ## Architecture & Integration
58
+
59
+ When you install this package, Docling discovers it automatically through standard Python package entry points.
60
+
61
+ ```mermaid
62
+ flowchart TD
63
+ A[Docling DocumentConverter] --> B[PdfPipeline]
64
+
65
+ subgraph Plugin System
66
+ C[Docling PluginManager] -.->|Discovers via entry-points| D[docling-pp-doc-layout]
67
+ D -.->|Registers| E[PPDocLayoutV3Model]
68
+ end
69
+
70
+ B -->|Initialization| C
71
+ B -->|Predict Layout Pages| E
72
+ E -->|Batched Tensors| F[HuggingFace AutoModel]
73
+ F -->|Raw Polygons / Boxes| E
74
+ E -->|Post-processed Clusters & BoundingBoxes| B
75
+ ```
76
+
77
+ ## Requirements
78
+
79
+ - Python 3.13+
80
+ - `docling>=2.73`
81
+ - `transformers>=5.1.0`
82
+ - `torch`
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ # with uv (recommended)
88
+ uv add docling-pp-doc-layout
89
+
90
+ # with pip
91
+ pip install docling-pp-doc-layout
92
+ ```
93
+
94
+ ## Usage
95
+
96
+ Using `docling-pp-doc-layout` is exactly like configuring standard Docling options.
97
+
98
+ ```python
99
+ from docling.document_converter import DocumentConverter, PdfFormatOption
100
+ from docling.datamodel.pipeline_options import PdfPipelineOptions
101
+ from docling_pp_doc_layout.options import PPDocLayoutV3Options
102
+
103
+ # 1. Define Pipeline Options
104
+ pipeline_options = PdfPipelineOptions()
105
+
106
+ # 2. Configure our custom PPDocLayoutV3Options
107
+ pipeline_options.layout_options = PPDocLayoutV3Options(
108
+ batch_size=8, # Tweak for GPU VRAM usage
109
+ confidence_threshold=0.5, # Filter low-confidence detections
110
+ model_name="PaddlePaddle/PP-DocLayoutV3_safetensors" # Target HuggingFace model repo
111
+ )
112
+
113
+ # 3. Create the converter
114
+ converter = DocumentConverter(
115
+ format_options={
116
+ "pdf": PdfFormatOption(pipeline_options=pipeline_options)
117
+ }
118
+ )
119
+
120
+ # 4. Convert Document
121
+ result = converter.convert("path/to/your/document.pdf")
122
+ print("Converted elements:", len(result.document.elements))
123
+ ```
124
+
125
+ ## Configuration Options
126
+
127
+ The `PPDocLayoutV3Options` dataclass gives you full control over the engine:
128
+
129
+ | Parameter | Type | Default | Description |
130
+ |-------------------------|---------|---------|-------------|
131
+ | `batch_size` | `int` | 8 | How many pages to process per single step. Decrease to lower memory usage; Increase to speed up processing of large documents. |
132
+ | `confidence_threshold` | `float` | 0.5 | The minimum confidence score (0.0 - 1.0) required to keep a layout detection cluster. |
133
+ | `model_name` | `str` | `"PaddlePaddle/PP-DocLayoutV3_safetensors"` | HuggingFace repository ID. Allows overriding if you host your local copy or a fine-tuned version. |
134
+
135
+
136
+ ## Development
137
+
138
+ If you wish to contribute or modify the plugin locally:
139
+
140
+ ```bash
141
+ git clone https://github.com/DCC-BS/docling-pp-doc-layout.git
142
+ cd docling-pp-doc-layout
143
+
144
+ # Install dependencies and pre-commit hooks
145
+ make install
146
+
147
+ # Run checks (ruff, ty) and tests (pytest)
148
+ make check
149
+ make test
150
+ ```
151
+
152
+ ## License
153
+
154
+ [MIT](LICENSE) © DCC Data Competence Center
@@ -0,0 +1,131 @@
1
+ # docling-pp-doc-layout
2
+
3
+ A [Docling](https://github.com/docling-project/docling) plugin that provides document layout detection using the PaddlePaddle PP-DocLayout-V3 model.
4
+
5
+ This plugin seamlessly integrates with Docling's standard pipeline to replace the default layout models with [PP-DocLayout-V3](https://huggingface.co/PaddlePaddle/PP-DocLayoutV3), enabling high-accuracy, instance segmentation-based layout analysis with polygon bounding box support, properly processed in optimized batches for enterprise scalability.
6
+
7
+ ---
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/DCC-BS/docling-pp-doc-layout">GitHub</a>
11
+ &nbsp;|&nbsp;
12
+ <a href="https://pypi.org/project/docling-pp-doc-layout/">PyPI</a>
13
+ </p>
14
+
15
+ ---
16
+
17
+ [![PyPI version](https://img.shields.io/pypi/v/docling-pp-doc-layout.svg)](https://pypi.org/project/docling-pp-doc-layout/)
18
+ [![Python versions](https://img.shields.io/pypi/pyversions/docling-pp-doc-layout.svg)](https://pypi.org/project/docling-pp-doc-layout/)
19
+ [![License](https://img.shields.io/github/license/DCC-BS/docling-pp-doc-layout)](https://github.com/DCC-BS/docling-pp-doc-layout/blob/main/LICENSE)
20
+ [![CI](https://github.com/DCC-BS/docling-pp-doc-layout/actions/workflows/main.yml/badge.svg)](https://github.com/DCC-BS/docling-pp-doc-layout/actions/workflows/main.yml)
21
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
22
+ [![Coverage](https://codecov.io/gh/DCC-BS/docling-pp-doc-layout/graph/badge.svg)](https://codecov.io/gh/DCC-BS/docling-pp-doc-layout)
23
+
24
+
25
+ ## Overview
26
+
27
+ `docling-pp-doc-layout` provides the `PPDocLayoutV3Model` layout engine for Docling. It automatically registers itself into Docling's plugin system upon installation. When configured in a Docling `DocumentConverter`, it intercepts page images, batches them, and infers document structural elements (text, tables, figures, headers, etc.) using HuggingFace's transformers library.
28
+
29
+ Key Features:
30
+ - **High Accuracy Layout Parsing**: Uses the RT-DETR instance segmentation framework.
31
+ - **Polygon Conversion**: Gracefully flattens complex polygon masks to Docling-compatible bounding boxes.
32
+ - **Enterprise Scalability**: Configurable batch sizing avoids out-of-memory (OOM) errors on large documents.
33
+
34
+ ## Architecture & Integration
35
+
36
+ When you install this package, Docling discovers it automatically through standard Python package entry points.
37
+
38
+ ```mermaid
39
+ flowchart TD
40
+ A[Docling DocumentConverter] --> B[PdfPipeline]
41
+
42
+ subgraph Plugin System
43
+ C[Docling PluginManager] -.->|Discovers via entry-points| D[docling-pp-doc-layout]
44
+ D -.->|Registers| E[PPDocLayoutV3Model]
45
+ end
46
+
47
+ B -->|Initialization| C
48
+ B -->|Predict Layout Pages| E
49
+ E -->|Batched Tensors| F[HuggingFace AutoModel]
50
+ F -->|Raw Polygons / Boxes| E
51
+ E -->|Post-processed Clusters & BoundingBoxes| B
52
+ ```
53
+
54
+ ## Requirements
55
+
56
+ - Python 3.13+
57
+ - `docling>=2.73`
58
+ - `transformers>=5.1.0`
59
+ - `torch`
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ # with uv (recommended)
65
+ uv add docling-pp-doc-layout
66
+
67
+ # with pip
68
+ pip install docling-pp-doc-layout
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ Using `docling-pp-doc-layout` is exactly like configuring standard Docling options.
74
+
75
+ ```python
76
+ from docling.document_converter import DocumentConverter, PdfFormatOption
77
+ from docling.datamodel.pipeline_options import PdfPipelineOptions
78
+ from docling_pp_doc_layout.options import PPDocLayoutV3Options
79
+
80
+ # 1. Define Pipeline Options
81
+ pipeline_options = PdfPipelineOptions()
82
+
83
+ # 2. Configure our custom PPDocLayoutV3Options
84
+ pipeline_options.layout_options = PPDocLayoutV3Options(
85
+ batch_size=8, # Tweak for GPU VRAM usage
86
+ confidence_threshold=0.5, # Filter low-confidence detections
87
+ model_name="PaddlePaddle/PP-DocLayoutV3_safetensors" # Target HuggingFace model repo
88
+ )
89
+
90
+ # 3. Create the converter
91
+ converter = DocumentConverter(
92
+ format_options={
93
+ "pdf": PdfFormatOption(pipeline_options=pipeline_options)
94
+ }
95
+ )
96
+
97
+ # 4. Convert Document
98
+ result = converter.convert("path/to/your/document.pdf")
99
+ print("Converted elements:", len(result.document.elements))
100
+ ```
101
+
102
+ ## Configuration Options
103
+
104
+ The `PPDocLayoutV3Options` dataclass gives you full control over the engine:
105
+
106
+ | Parameter | Type | Default | Description |
107
+ |-------------------------|---------|---------|-------------|
108
+ | `batch_size` | `int` | 8 | How many pages to process per single step. Decrease to lower memory usage; Increase to speed up processing of large documents. |
109
+ | `confidence_threshold` | `float` | 0.5 | The minimum confidence score (0.0 - 1.0) required to keep a layout detection cluster. |
110
+ | `model_name` | `str` | `"PaddlePaddle/PP-DocLayoutV3_safetensors"` | HuggingFace repository ID. Allows overriding if you host your local copy or a fine-tuned version. |
111
+
112
+
113
+ ## Development
114
+
115
+ If you wish to contribute or modify the plugin locally:
116
+
117
+ ```bash
118
+ git clone https://github.com/DCC-BS/docling-pp-doc-layout.git
119
+ cd docling-pp-doc-layout
120
+
121
+ # Install dependencies and pre-commit hooks
122
+ make install
123
+
124
+ # Run checks (ruff, ty) and tests (pytest)
125
+ make check
126
+ make test
127
+ ```
128
+
129
+ ## License
130
+
131
+ [MIT](LICENSE) © DCC Data Competence Center
@@ -0,0 +1,15 @@
1
+ coverage:
2
+ status:
3
+ project:
4
+ default:
5
+ target: 80%
6
+ threshold: 2%
7
+ patch:
8
+ default:
9
+ target: 80%
10
+ threshold: 5%
11
+
12
+ comment:
13
+ layout: "reach, diff, flags, files"
14
+ behavior: default
15
+ require_changes: false