Object Detection
Transformers
Safetensors
PaddleOCR
English
Chinese
multilingual
pp_doclayout_v4
PaddlePaddle
ocr
layout
layout_detection
reading_order
Instructions to use PaddlePaddle/PP-DocLayoutV4_safetensors with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PaddlePaddle/PP-DocLayoutV4_safetensors with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="PaddlePaddle/PP-DocLayoutV4_safetensors")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForObjectDetection processor = AutoImageProcessor.from_pretrained("PaddlePaddle/PP-DocLayoutV4_safetensors") model = AutoModelForObjectDetection.from_pretrained("PaddlePaddle/PP-DocLayoutV4_safetensors", device_map="auto") - PaddleOCR
How to use PaddlePaddle/PP-DocLayoutV4_safetensors 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_safetensors") 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
Update geometry-enabled PP-DocLayoutV4 checkpoint
Browse filesUpdate model weights, configuration, image processor configuration, and original Paddle inference metadata together. Validated with local Transformers end-to-end inference and Paddle comparisons.
Files changed (3)
- config.json+23-2
- inference.yml+54-61
- model.safetensors+2-2
6 unmodified lines789101112131415161718195 unmodified lines2526272829303113 unmodified lines45464748495085 unmodified lines13613713813914014190 unmodified lines2322332342352366 unmodified lines],"attention_dropout": 0.0,"backbone_config": {"arch": "L","depths": [3,4,6,3],"embedding_size": 64,"freeze_at": 0,"freeze_norm": true,5 unmodified lines1024,2048],"initializer_range": 0.02,"lr_mult_list": [0,0.05,13 unmodified lines3,4],"return_idx": [1,2,85 unmodified lines],"decoder_layers": 6,"decoder_n_points": 4,"disable_custom_kernels": true,"dropout": 0.0,"dtype": "float32",90 unmodified lines"s2r_damping": 0.5,"s2r_steps": 3,"tie_word_embeddings": true,"transformers_version": "5.18.0.dev0"}6 unmodified lines789101112131415161718192021225 unmodified lines2829303132333435363738394041424313 unmodified lines5758596061626364656685 unmodified lines15215315415515615715815916016116290 unmodified lines2532542552562576 unmodified lines],"attention_dropout": 0.0,"backbone_config": {"_name_or_path": "","architectures": null,"chunk_size_feed_forward": 0,"depths": [3,4,6,3],"dtype": null,"embedding_size": 64,"freeze_at": 0,"freeze_norm": true,5 unmodified lines1024,2048],"id2label": {"0": "LABEL_0","1": "LABEL_1"},"initializer_range": 0.02,"is_encoder_decoder": false,"label2id": {"LABEL_0": 0,"LABEL_1": 1},"lr_mult_list": [0,0.05,13 unmodified lines3,4],"output_attentions": false,"output_hidden_states": false,"problem_type": null,"return_dict": true,"return_idx": [1,2,85 unmodified lines],"decoder_layers": 6,"decoder_n_points": 4,"deform_conv_width": 128,"deform_kbins": 41,"deform_krange": 1.5,"deform_level": 1,"deform_pred": true,"disable_custom_kernels": true,"dropout": 0.0,"dtype": "float32",90 unmodified lines"s2r_damping": 0.5,"s2r_steps": 3,"tie_word_embeddings": true,"transformers_version": "5.21.0.dev0"}
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596012 unmodified lines737475767778798020 unmodified lines101102103104105106107Global:model_name: PP-DocLayoutV4Hpi:backend_configs:paddle_infer: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.67trt_dynamic_shapes: &id001im_shape:- - 1- 2- - 1- 2- - 8- 2image:- - 1- 3- 800- 800- - 1- 3- 800- 800- - 8- 3- 800- 800scale_factor:- - 1- 2- - 1- 2- - 8- 2tensorrt:dynamic_shapes: *id001Preprocess:- interp: 2keep_ratio: false12 unmodified lines- 1.0type: NormalizeImage- type: Permutearch: DETRdraw_threshold: 0.5label_list:- abstract- algorithm20 unmodified lines- text- vertical_text- vision_footnotemetric: COCOmin_subgraph_size: 3mode: paddleuse_dynamic_shape: false123456789101112 unmodified lines24252627282920 unmodified lines5051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100mode: paddledraw_threshold: 0.5metric: COCOuse_dynamic_shape: falseGlobal:model_name: PP-DocLayoutV4arch: DETRmin_subgraph_size: 3Preprocess:- interp: 2keep_ratio: false12 unmodified lines- 1.0type: NormalizeImage- type: Permutelabel_list:- abstract- algorithm20 unmodified lines- text- vertical_text- vision_footnoteHpi:backend_configs:paddle_infer:trt_dynamic_shapes: &id001image:- - 1- 3- 800- 800- - 1- 3- 800- 800- - 8- 3- 800- 800scale_factor:- - 1- 2- - 1- 2- - 8- 2trt_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.67tensorrt:dynamic_shapes: *id001
123version https://git-lfs.github.com/spec/v1oid sha256:795a31b66ac02d5c9fb79ed40167f3849711d7f7aa43547ce6bb52986558e844size 135296568123version https://git-lfs.github.com/spec/v1oid sha256:1d12178013dab1f51a663f21cda7bc24e49b77afa91441dd03167e3289d8ef71size 137713624
config.json+23-2
inference.yml+54-61
model.safetensors+2-2