Expand description
Layout detection on the shared ONNX Runtime layer (#641). Off by default. Layout detection on the shared ONNX Runtime layer (#641).
Behind the ort-layout cargo feature (off by default). Turns one PDF page
into the layout detector’s boxes, exactly as the Python reference does
(Heron-ft ep03, RT-DETRv2, HF transformers 4.57.6 post-processing):
LAYOUT_EP03is the model, loaded throughpdf_ocr::runtime::sessiononly.render_page_rgbrenders the page at 96 dpi, RGB on white, through the same calls as therender_page_pngexample. No new renderer.preprocess_to_nchwresizes to 640x640 non-uniform with PIL BILINEAR (triangle support widened on downscale, as PIL does), rescales by 1/255 with no mean/std normalisation, and lays out NCHWf321x3x640x640 – the flags in the model’spreprocessor_config.json(RTDetrImageProcessor,do_resize,do_rescale, nodo_normalize, nodo_pad).layout_boxesruns the graph (input/output names read from the ONNX session metadata, as exported:pixel_valuesin,logitsandpred_boxesout) and post-processes exactly as HFpost_process_object_detectionfor RT-DETR: sigmoid over the logits, top-300 over the flattened scores,label = index % 17,query = index / 17, boxes from normalised cxcywh to xyxy scaled to the render size, keepingscore >= 0.05. Label names are the model’sconfig.jsonid2label.
Model failures come back as EngineError::Io
carrying the typed pdf_ocr::runtime::ModelError
– no new EngineError variants. Callers match that variant and find the
cause with
pdf_ocr::runtime::model_error.
Re-exports§
pub use crate::model::LAYOUT_EP03;
Structs§
- Layout
Box - One layout detection: what the region is, where it is on the render.
- RgbPage
- An 8-bit RGB page render at 96 dpi, row-major, three bytes per pixel.
- Runtime
Config - How the shared layer resolves files and sizes its pools.
Functions§
- layout_
boxes - The layout detector’s boxes for one page.
- preprocess_
to_ nchw - Preprocess a render into the detector’s NCHW
f32input (1x3x640x640). - render_
page_ rgb - Render one page at 96 dpi, RGB on white.