How to use from the
Use from the
LiteRT library
# No code snippets available yet for this library.

# To use this model, check the repository files and the library's documentation.

# Want to help? PRs adding snippets are welcome at:
# https://github.com/huggingface/huggingface.js

PP-DocLayoutV3 for LiteRT

FP32 LiteRT/TFLite export of PP-DocLayoutV3 from the official PaddlePaddle safetensors checkpoint. It predicts 25 document-layout categories, bounding boxes, region masks, and reading order. Host postprocessing converts these raw outputs into page coordinates and polygons. Text recognition is a separate step.

Source checkpoint: PaddlePaddle/PP-DocLayoutV3_safetensors, revision e4f489dc536556fc1be02b973ba06756e0d4a2ac.

Model file

PP-DocLayoutV3-fp32.tflite · FP32 · 133.97 MB. The file hash is in SHA256SUMS.

The TFLite signature is main. All input and output tensors are float32; shapes are fixed. Image/video decoding, preprocessing, and application postprocessing run on the host.

Direction Name Shape Meaning
Input pixel_values [1, 3, 800, 800] RGB page in [0, 1], NCHW
Output class_logits [1, 300, 25] 300 queries × 25 layout-class logits
Output boxes_cxcywh [1, 300, 4] Normalized center-x, center-y, width, height
Output order_logits [1, 300, 300] Pairwise reading-order logits for 300 queries
Output mask_logits [1, 300, 200, 200] Per-query mask logits at 200 × 200

Preprocessing and outputs

Convert the page to RGB and use the pinned upstream image processor: bicubic resize to 800 × 800, rescale by 1/255, and NCHW layout. Its normalization mean is [0, 0, 0] and standard deviation is [1, 1, 1]. The example uses the source processor for both preprocessing and postprocessing.

Class scores and masks are logits. Boxes use normalized (center_x, center_y, width, height) coordinates. Use the upstream postprocessor to filter predictions, produce polygons, rescale to the original page size, and recover reading order. Class names are in labels.json.

Run on CPU

pip install ai-edge-litert huggingface_hub numpy pillow "transformers==5.21.0" torch torchvision opencv-python-headless
import numpy as np
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter
import json
import torch
from pathlib import Path
from PIL import Image
from types import SimpleNamespace
from transformers import AutoImageProcessor

processor = AutoImageProcessor.from_pretrained(
    "PaddlePaddle/PP-DocLayoutV3_safetensors",
    revision="e4f489dc536556fc1be02b973ba06756e0d4a2ac",
)
image = Image.open("page.jpg").convert("RGB")
pixel_values = processor(images=image, return_tensors="pt")["pixel_values"].numpy()
pixel_values = np.ascontiguousarray(pixel_values, dtype=np.float32)

model_path = hf_hub_download("litert-community/PP-DocLayoutV3", "PP-DocLayoutV3-fp32.tflite")
interpreter = Interpreter(model_path=model_path, num_threads=4)
interpreter.allocate_tensors()
run = interpreter.get_signature_runner("main")
raw = run(pixel_values=pixel_values)
outputs = SimpleNamespace(
    logits=torch.from_numpy(raw["class_logits"]),
    pred_boxes=torch.from_numpy(raw["boxes_cxcywh"]),
    order_logits=torch.from_numpy(raw["order_logits"]),
    out_masks=torch.from_numpy(raw["mask_logits"]),
)
result = processor.post_process_object_detection(
    outputs, threshold=0.5, target_sizes=[(image.height, image.width)]
)[0]
labels_path = hf_hub_download("litert-community/PP-DocLayoutV3", "labels.json")
labels = json.loads(Path(labels_path).read_text())
for score, label, box, polygon, order in zip(
    result["scores"], result["labels"], result["boxes"],
    result["polygon_points"], result["order_seq"],
):
    print(labels[str(label.item())], float(score), box.tolist(), polygon, int(order))

Source and license

PP-DocLayoutV3 is developed by the PaddleOCR team. See the PaddleOCR project and RT-DocLayout paper. The example uses Transformers 5.21.0 for the host image processor; the neural network runs in LiteRT.

This FP32 conversion uses the original pretrained weights with a fixed-shape TFLite interface. License: Apache 2.0.

Citation

@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}
}
Downloads last month
12
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for litert-community/PP-DocLayoutV3

Finetuned
(4)
this model

Paper for litert-community/PP-DocLayoutV3