Views
No views yet

1import requests
2from PIL import Image
3from transformers import AutoImageProcessor, AutoModelForObjectDetection
4
5model_path = "PaddlePaddle/PP-DocLayoutV3_safetensors"
6model = AutoModelForObjectDetection.from_pretrained(model_path)
7image_processor = AutoImageProcessor.from_pretrained(model_path)
8
9image = Image.open(requests.get("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/layout_demo.jpg", stream=True).raw)
10inputs = image_processor(images=image, return_tensors="pt")
11
12outputs = model(**inputs)
13results = image_processor.post_process_object_detection(outputs, target_sizes=[image.size[::-1]])
14for result in results:
15 for idx, (score, label_id, box, polygon_points) in enumerate(zip(result["scores"], result["labels"], result["boxes"], result["polygon_points"])):
16 score, label = score.item(), label_id.item()
17 box = [round(i, 2) for i in box.tolist()]
18 print(f"Order {idx + 1}: {model.config.id2label[label]}, score: {score:.2f}, box: {box}, polygon_points: {polygon_points}")



1@misc{cui2026rtdoclayoutrealtimeendtoenddocument,
2 title={RT-DocLayout: Real-Time End-to-End Document Layout Analysis with Reading Order in the Wild},
3 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},
4 year={2026},
5 eprint={2606.23344},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2606.23344},
9}
10}
11