| Model | FP32 | Task |
|---|---|---|
| Docling-Layout-Heron | docling-layout-heron.onnx, docling-layout-heron.onnx_data | layout detection |
| TableFormer | tableFormer_encoder.onnx, tableFormer_encoder.onnx_data, tableFormer_decoder.onnx, tableFormer_decoder.onnx_data, tableFormer_box.onnx, tableFormer_box.onnx_data | table structure recognition |
# onnxruntime-gpu for run it on GPU
pip install onnxruntime opencv-python numpy
Every model folder has the same layout:
src/helper.py = onnx session builder (provider selection, threads, memory options)src/example.py = full pipeline: image preprocess, inference, postprocessonnx/ = the model files: xxx.onnx (structure) and xxx.onnx_data (weight), keep them in the same folderRun the commands from the repository root.
Test images used by the examples:
python3 Docling-Layout-Heron/src/example.py jp_1.jpg
0.956688 | table | [1066, 852, 1692, 991]
0.951113 | table | [57, 397, 1691, 782]
0.932638 | table | [1063, 176, 1692, 260]
0.929594 | page_footer | [1069, 1159, 1199, 1176]
0.878344 | section_header | [797, 141, 953, 166]
Note:
pixel_values, the only input, fixed shape [1, 3, 640, 640].logits [1, 300, 17] (raw, apply the sigmoid) and pred_boxes [1, 300, 4] as[centerX, centerY, width, height] in the 0..1 range: multiply by the original image size.python3 TableFormer/src/example.py Table_1.jpg
fcel fcel fcel fcel fcel fcel fcel fcel fcel fcel nl
rhed fcel fcel fcel fcel fcel fcel fcel fcel fcel nl
rhed fcel fcel fcel fcel fcel fcel fcel fcel fcel nl
rhed fcel fcel fcel fcel fcel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed ecel ecel ecel ecel ecel fcel fcel fcel fcel nl
rhed lcel lcel lcel fcel fcel fcel fcel fcel fcel nl
[24, 31, 127, 79]
[180, 33, 279, 79]
[333, 27, 436, 83]
[581, 35, 866, 84]
[1003, 6, 1094, 78]
Note:
table boxes from Docling-Layout-Heron.[channel, width, height] (width before height) with batch dimension.tableFormer_encoder.onnx = feed image [1, 3, 448, 448], output memory [784, 1, 512] and box [1, 784, 512];tableFormer_decoder.onnx = one tag per call, feed tag [1], position [1], memory and buffer [6, 1024, 1, 512],logit [1, 13], hidden [1, 512] and state [6, 1, 1, 512];tableFormer_box.onnx = feed box and hidden [32, 512] (zero padded), output class [32, 3] and coordinate [32, 4].<start>, write state in buffer[:, position] after every call, stop at <end>fcel cell with content, ecel empty cell, lcel merged with the cell on the left, ucel merged withxcel merged with both, ched column header, rhed row header, srow section row, nl end of the row.lcel, ucel, xcel and nl have no box), [x1, y1, x2, y2] in the table crop space.Docling-Layout-Heron/onnx/docling-layout-heron.onnx 525.9 KiBTableFormer/onnx/tableFormer_encoder.onnx 109.5 KiBTableFormer/onnx/tableFormer_decoder.onnx 61.4 KiBTableFormer/onnx/tableFormer_box.onnx 6.3 KiB