|
Download README.md from cimo001/docling: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/cimo001/docling/resolve/main/README.md
- Command line
-
hf download hf://cimo001/docling/README.md
-
curl -L -o README.md https://huggingface.co/cimo001/docling/resolve/main/README.md
4.73 kB
metadata
license: apache-2.0
base_model: docling-project
pipeline_tag: object-detection
library_name: onnx
language:
- multilingual
tags:
- layout
- docling
- onnx
ONNX - Docling
| Model | FP32 | Task |
|---|---|---|
| Docling-Layout-Heron | docling-layout-heron.onnx | layout detection |
| TableFormer | tableFormer_encoder.onnx, tableFormer_decoder.onnx, tableFormer_box.onnx | table structure recognition |
Usage
# 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 file
Run the commands from the repository root.
Test images used by the examples:
- jp_1.jpg = full page
- Table_1.jpg = single table
Docling-Layout-Heron
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:
- Input = RGB image resized to 640x640 (bilinear), float32 0..1, CHW with batch dimension.
- Feed =
pixel_values, the only input, fixed shape[1, 3, 640, 640]. - Output =
logits[1, 300, 17](raw, apply the sigmoid) andpred_boxes[1, 300, 4]as
[centerX, centerY, width, height]in the 0..1 range: multiply by the original image size. - 17 label classes (caption, footnote, formula, list_item, page_footer, page_header, picture, section_header,
table, text, title, ...): full list in Docling-Layout-Heron/src/example.py. - 300 queries per image, no NMS in the model: filter by score (0.5 in the example) and handle the overlap
on your side. The same box can come out with two labels.
TableFormer
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:
- Input = a single table crop, not a full page: use the
tableboxes from Docling-Layout-Heron. - Input = RGB image resized to height 1024, normalized with the table mean / std (values in the example),
resized to 448x448, transposed to[channel, width, height](width before height) with batch dimension. - Three graphs, exported with fixed shapes:
tableFormer_encoder.onnx= feedimage[1, 3, 448, 448], outputmemory[784, 1, 512]andbox[1, 784, 512];
tableFormer_decoder.onnx= one tag per call, feedtag[1],position[1],memoryandbuffer[6, 1024, 1, 512],
outputlogit[1, 13],hidden[1, 512]andstate[6, 1, 1, 512];
tableFormer_box.onnx= feedboxandhidden[32, 512](zero padded), outputclass[32, 3]andcoordinate[32, 4]. - Decode = greedy: start from
<start>, writestateinbuffer[:, position]after every call, stop at<end>
or at 1024 tags. - Tag = OTSL:
fcelcell with content,ecelempty cell,lcelmerged with the cell on the left,ucelmerged with
the cell above,xcelmerged with both,chedcolumn header,rhedrow header,srowsection row,nlend of the row. - The first output of the example is the grid, one line per table row. The second is one box per cell, in the same
order as the cells of the grid (lcel,ucel,xcelandnlhave no box),[x1, y1, x2, y2]in the table crop space. - A cell merged over several columns gets a single box that goes from its first to its last column.
- The model gives the structure only: read the text with an OCR model and assign it to the cells by box overlap.