D-FINE nano DocLayNet: document layout detection

A 3.7M-parameter D-FINE nano detector that finds layout regions on document pages: Caption, Footnote, Formula, List-item, Page-footer, Page-header, Picture, Section-header, Table, Text and Title.

Fine-tuned from ustc-community/dfine-nano-coco on the full DocLayNet v1.2 training set, with pages containing Footnote, Formula or Title repeated 3x. 12 epochs at 1024x1024 on one A100.

It is small enough to run in a browser: onnx/layout_fp16.onnx (8 MB) runs in onnxruntime-web on WebGPU at roughly 40 ms per page.

License

Apache-2.0, like the D-FINE base weights. Training data: DocLayNet (CDLA-Permissive-1.0) by IBM Research.

Usage

import numpy as np, torch
from PIL import Image
from transformers import DFineForObjectDetection

model = DFineForObjectDetection.from_pretrained("avbiswas/dfine-nano-doclaynet").eval()
page = Image.open("page.png").convert("RGB")          # render PDF pages at ~144 DPI
W, H = page.size
x = torch.from_numpy(np.asarray(page.resize((1024, 1024)), dtype=np.float32) / 255)
x = x.permute(2, 0, 1)[None]                           # plain resize + /255, no mean/std normalisation

with torch.no_grad():
    out = model(pixel_values=x)
scores, labels = out.logits[0].sigmoid().max(-1)       # 300 queries, one class each, no NMS
for (cx, cy, w, h), c, s in zip(out.pred_boxes[0].tolist(), labels.tolist(), scores.tolist()):
    if s >= 0.5:
        print(model.config.id2label[c], round(s, 2), [(cx - w/2) * W, (cy - h/2) * H, (cx + w/2) * W, (cy + h/2) * H])

Results

mAP50-95 on a 2,500-page DocLayNet v1.2 test subset (shards 0, 2 and 4 of the official test split), at 1024 px:

Class This model (D-FINE nano, 3.7M) hantian/yolo-doclaynet YOLO11s (~9.4M)
All 0.652 0.744
mAP50 (all) 0.828 0.906
Caption 0.614 0.793
Footnote 0.454 0.620
Formula 0.597 0.714
List-item 0.706 0.816
Page-footer 0.666 0.569
Page-header 0.704 0.698
Picture 0.657 0.787
Section-header 0.620 0.711
Table 0.671 0.819
Text 0.793 0.852
Title 0.686 0.803

The YOLO11s numbers come from a different evaluation script (Ultralytics' validator) on the same pages, so treat the comparison as approximate. This model trades some accuracy for size and a permissive license; avbiswas/yolo11n-doclaynet scores higher (0.760) but is AGPL-3.0.

Downloads last month
169
Safetensors
Model size
3.75M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for avbiswas/dfine-nano-doclaynet

Quantized
(5)
this model

Dataset used to train avbiswas/dfine-nano-doclaynet

Paper for avbiswas/dfine-nano-doclaynet