yolo26m-doc-layout-onnx
An ONNX export of Armaggheddon/yolo26-document-layout
(yolo26m_doc_layout.pt), a DocLayNet-trained document-layout detector. All
credit for the weights goes to that repository; this one only changes the
container format.
Why the export exists. The weights are MIT, but the runtime that loads a
.pt is ultralytics, which is AGPL-3.0 and cannot ship inside a proprietary
image. The ONNX graph runs on onnxruntime (MIT), so exporting once separates
the license of the model from the license of the loader. Nothing downstream
needs ultralytics or torch.
Files
| File | Size | Export |
|---|---|---|
yolo26m_doc_layout.onnx |
82 MB | imgsz=1280, opset=17, simplify=True |
sha256 b143fbb74dbd24ae5b7ebf7b94e78983e02660e4175242b2d2a0f83575848373
Use 1280. These weights were trained at 1280 and degrade at the ultralytics default of 640. The input shape is pinned in the graph, so a mismatched letterbox is a runtime error at best and silently rescaled boxes at worst.
Classes
The export carries its names metadata, so class ids map to labels without
being told the order โ 11 DocLayNet classes:
Caption, Footnote, Formula, List-item, Page-footer, Page-header,
Picture, Section-header, Table, Text, Title
Usage
curl -fsSL -o yolo26m_doc_layout.onnx \
https://huggingface.co/superchaintech/yolo26m-doc-layout-onnx/resolve/main/yolo26m_doc_layout.onnx
echo "b143fbb74dbd24ae5b7ebf7b94e78983e02660e4175242b2d2a0f83575848373 yolo26m_doc_layout.onnx" | sha256sum -c
import numpy as np, onnxruntime
from PIL import Image
session = onnxruntime.InferenceSession(
"yolo26m_doc_layout.onnx", providers=["CPUExecutionProvider"],
)
# letterbox your page to 1280x1280, CHW, float32 /255, then:
# outputs = session.run(None, {session.get_inputs()[0].name: batch})
With sc_toolkit, which wraps
letterboxing, NMS and the label mapping:
import os
os.environ["SC_LAYOUT_MODEL_DIR"] = "/opt/layout"
from sc_toolkit.vlm.hybrid.detectors import load_onnx_detector
detector = load_onnx_detector("yolo26m_doc_layout.onnx")
regions = detector.detect(page_image, 0.25) # 0.25 is the YOLO calibration
min_conf matters: 0.25 is the calibration for this backend. 0.5 is the
PP-DocLayoutV3 number and drops span coverage to ~79%.
Measured behaviour
Six real pages (a KPMG accounting paper and a Hong Kong annual report) at 150
dpi, min_conf=0.25: 78 regions found, no empty page, top confidences
0.84โ0.99.
Reproducing the export
pip install ultralytics huggingface_hub onnx
python -c "from huggingface_hub import hf_hub_download; from ultralytics import YOLO; \
w = hf_hub_download('Armaggheddon/yolo26-document-layout', 'yolo26m_doc_layout.pt'); \
print(YOLO(w).export(format='onnx', imgsz=1280, opset=17, simplify=True))"
Model tree for superchaintech/yolo26m-doc-layout-onnx
Base model
Ultralytics/YOLO26