Views
No views yet
PaddlePaddle/PP-DocLayoutV3_safetensors
PyTorch/HF Transformers port. Produced for
RailReaderCore's native
WebGPU execution provider support (RailReader.Core.Analysis.WebGpu).stefanj0/PP-DocLayoutV3-ONNX
export (same [N,7] detection-tensor contract, including reading order)
intended for GPU inference. The backbone/encoder/decoder run in FP16; the
sigmoid/top-k box-decode and reading-order-vote postprocessing are kept in
FP32 for numerical stability. The mask/polygon segmentation head this HF port
also exposes is not included — RailReaderCore's consumer never reads it.onnxconverter_common) does not work for this model — an iterative
type-mismatch auto-fixer made progress but never converged, repeatedly
re-upcasting decoder weights back toward FP32. Exporting fresh from the
PyTorch/HF source avoids this: the tracer keeps every op's dtype consistent
throughout. This also required one extra step beyond a plain PyTorch export:
onnxsim's constant-folding, to resolve a WebGPU execution-provider
graph-partitioning failure on the model's static sinusoidal
position-embedding subgraph (loads fine on CPU EP either way).| metric | value |
|---|---|
| block-centroid match, real document page | 14/14 blocks match, sub-pixel differences only |
| block-centroid match, additional test page | 4/4 blocks, exact match |
| inference speedup (WebGPU EP vs CPU EP, laptop-class GPU) | ~7.3× |
image float [1,3,800,800] NCHW, already letterboxed and
rescaled to [0,1] (no mean/std normalization); im_shape float [1,2]
(target canvas size, e.g. [800,800]); scale_factor float [1,2]
(always [1,1] in this pipeline — kept as a real graph input for contract
parity, not used numerically).det float [300,7] = [classId, confidence, xmin, ymin, xmax, ymax, readingOrder], no batch dimension.torch.onnx.export from a wrapper around
PPDocLayoutV3ForObjectDetection.from_pretrained("PaddlePaddle/PP-DocLayoutV3_safetensors").half(),
replicating that model's own PPDocLayoutV3ImageProcessor.post_process_object_detection
and _get_order_seqs in FP32, then simplified with onnxsim. Requires
transformers>=5 to load the source checkpoint (pp_doclayout_v3 isn't
registered in older releases). Full reproducible tooling:
tools/onnx-fp16-export/export_v3_fp16.py in RailReaderCore.PaddlePaddle/PP-DocLayoutV3_safetensors.