Object Detection
PaddleOCR
English
Chinese
multilingual
PaddlePaddle
ocr
layout
layout_detection
reading_order
Instructions to use PaddlePaddle/PP-DocLayoutV4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PaddleOCR
How to use PaddlePaddle/PP-DocLayoutV4 with PaddleOCR:
# 1. See https://www.paddlepaddle.org.cn/en/install to install paddlepaddle # 2. pip install paddleocr from paddleocr import LayoutDetection model = LayoutDetection(model_name="PP-DocLayoutV4") output = model.predict(input="path/to/image.png", batch_size=1) for res in output: res.print() res.save_to_img(save_path="./output/") res.save_to_json(save_path="./output/res.json") - Notebooks
- Google Colab
- Kaggle
Add PP-DocLayoutV4 static-graph inference model
Browse filesFiles changed (5)
- .gitattributes+1
- README.md+131
- inference.jsonAdded
- inference.pdiparamsAdded+3
- inference.ymlAdded+100
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textinference.pdiparams filter=lfs diff=lfs merge=lfs -text
123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134---license: apache-2.0pipeline_tag: object-detectiontags:- PaddleOCR- PaddlePaddle- ocr- layout- layout_detection- reading-orderlanguage:- en- zh- multilingual---# PP-DocLayoutV4Document layout analysis model in **PaddlePaddle inference (static graph)**format. For the safetensors weights see[PP-DocLayoutV4_safetensors](https://huggingface.co/PaddlePaddle/PP-DocLayoutV4_safetensors).## IntroductionPP-DocLayoutV4 is built on DETR with a PPHGNetV2-L backbone. In a single forwardpass it predicts, for each of 25 layout categories:* a **4-point quadrilateral** rather than only an axis-aligned box, which keepsskewed and rotated regions tight — newspapers, multi-column magazines andphotographed pages in particular;* the **reading order**, modelled with S2R (Successor → Relation): the networkemits a direct-successor matrix and a relative-order matrix, from which thereading sequence is decoded during post-processing.It is the layout component of the PaddleOCR-VL-1.6 pipeline.### Relation to PP-DocLayoutV3| | PP-DocLayoutV3 | PP-DocLayoutV4 ||-|-|-|| Region shape | instance-segmentation mask → polygon | 4-point quadrilateral || Reading order | decoded inside the graph | S2R logits, decoded in post-processing || Categories | 25 (identical) | 25 (identical) || Input | 800 × 800 | 800 × 800 (identical preprocessing) |Both share the same label set and preprocessing, so V4 is a drop-in replacementwherever V3 was used — except that V4 returns `quad` instead of`polygon_points`.## Model Usage```pythonfrom paddlex import create_predictorpredictor = create_predictor(model_name="PP-DocLayoutV4",model_dir="<path to this repository>",engine="paddle_static",)for res in predictor.predict("layout.jpg",threshold=0.3,layout_nms=True,layout_shape_mode="auto",):res.save_to_img("./output")res.save_to_json("./output")```Each detected region is returned as:```python{"cls_id": 22,"label": "text","score": 0.994,"coordinate": [33.3, 347.9, 363.2, 615.3], # axis-aligned box"quad": [[33.3, 347.9], [363.2, 347.9], # 4-point quadrilateral[363.1, 615.0], [33.2, 615.3]],"order": 2, # reading order, 1-based}````order` is `None` for categories excluded from the reading sequence (headers,footers, images, tables, captions and similar).### Graph signature| | name | shape | dtype ||-|-|-|-|| input | `im_shape` | `[-1, 2]` | float32 || input | `image` | `[-1, 3, 800, 800]` | float32 || input | `scale_factor` | `[-1, 2]` | float32 || output 0 | boxes | `[-1, 10]` | float32 || output 1 | box count | `[-1]` | int32 || output 2 | query indices | `[-1, 300]` | int64 || output 3 | relative-order logits | `[-1, 300, 300]` | float32 || output 4 | successor-order logits | `[-1, 300, 300]` | float32 |Output 0 columns are `[label, score, x1, y1, x2, y2, x3, y3, x4, y4]` withcorners in TL → TR → BR → BL order, in original-image coordinates. Output 1 is aconstant 300 — every query is emitted, and the score threshold is applied duringpost-processing.## Categories`abstract`, `algorithm`, `aside_text`, `chart`, `content`, `display_formula`,`doc_title`, `figure_title`, `footer`, `footer_image`, `footnote`,`formula_number`, `header`, `header_image`, `image`, `inline_formula`, `number`,`paragraph_title`, `reference`, `reference_content`, `seal`, `table`, `text`,`vertical_text`, `vision_footnote`## Files| File | Purpose ||-|-|| `inference.json` | PIR program (static graph) || `inference.pdiparams` | weights || `inference.yml` | labels, preprocessing and HPI metadata |## Citation```bibtex@misc{cui2026rtdoclayoutrealtimeendtoenddocument,title={RT-DocLayout: Real-Time End-to-End Document Layout Analysis with Reading Order in the Wild},author={Cheng Cui and Tingquan Gao and Xueqing Wang and Changda Zhou and Hongen Liu and Ting Sun and Yubo Zhang and Zelun Zhang and Jiaxuan Liu and Manhui Lin and Yue Zhang and Suyin Liang and Yiqing Xiang and Yi Liu},year={2026},eprint={2606.23344},archivePrefix={arXiv},primaryClass={cs.CV},url={https://arxiv.org/abs/2606.23344},}```
123version https://git-lfs.github.com/spec/v1oid sha256:92f0604587087a55daa44f9306c8ce8037b918fdf07d975f5c591edde4043271size 130354792123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100mode: paddledraw_threshold: 0.5metric: COCOuse_dynamic_shape: falseGlobal: model_name: PP-DocLayoutV4arch: DETRmin_subgraph_size: 3Preprocess:- interp: 2 keep_ratio: false target_size: - 800 - 800 type: Resize- mean: - 0.0 - 0.0 - 0.0 norm_type: none std: - 1.0 - 1.0 - 1.0 type: NormalizeImage- type: Permutelabel_list:- abstract- algorithm- aside_text- chart- content- display_formula- doc_title- figure_title- footer- footer_image- footnote- formula_number- header- header_image- image- inline_formula- number- paragraph_title- reference- reference_content- seal- table- text- vertical_text- vision_footnoteHpi: backend_configs: paddle_infer: trt_dynamic_shapes: &id001 image: - - 1 - 3 - 800 - 800 - - 1 - 3 - 800 - 800 - - 8 - 3 - 800 - 800 scale_factor: - - 1 - 2 - - 1 - 2 - - 8 - 2 trt_dynamic_shape_input_data: scale_factor: - - 2 - 2 - - 1 - 1 - - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 - 0.67 tensorrt: dynamic_shapes: *id001.gitattributes+1
README.md+131
inference.jsonAdded
inference.pdiparamsAdded+3
inference.ymlAdded+100