Instructions to use juliozhao/DocLayout-YOLO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use juliozhao/DocLayout-YOLO with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("juliozhao/DocLayout-YOLO", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
DocLayout-YOLO — Model Checkpoints
Official checkpoints for DocLayout-YOLO, a document-specialized real-time detector built on YOLOv12 with Page-Axis Layout Attention (PALA) and mesh-guided synthetic pretraining.
Checkpoints
Pretrained models (for fine-tuning on your own layout datasets), trained on large-scale synthetic document pretraining data:
- DocLayout-YOLO-pretrain-N.pt
- DocLayout-YOLO-pretrain-S.pt
- DocLayout-YOLO-pretrain-M.pt
- DocLayout-YOLO-pretrain-L.pt
- DocLayout-YOLO-pretrain-X.pt
Downstream models (fine-tuned on four public document-layout benchmarks, five model sizes each), under downstream/:
General-purpose model (22 fine-grained layout categories, drop-in front-end for document parsing pipelines):
Quick inference:
from ultralytics import YOLO
model = YOLO("DocLayout-YOLO-universal.pt") # download from the link above
results = model.predict("page.png", imgsz=1024, conf=0.25, iou=0.5, verbose=False)
results[0].save(filename="result.jpg")
Or try it online without any setup: Online Demo (ModelScope).
Main Results (mAP50-95)
| Model | D4LA | M6Doc | HJDataset | PRIMA-LAD |
|---|---|---|---|---|
| n | 67.2 | 66.2 | 93.6 | 67.7 |
| s | 70.6 | 71.1 | 94.8 | 70.3 |
| m | 70.7 | 73.3 | 95.3 | 71.3 |
| l | 72.4 | 75.1 | 95.7 | 73.4 |
| x | 72.4 | 75.5 | 96.0 | 73.1 |
Click a score to download the corresponding checkpoint.
Datasets
The four downstream benchmarks are released as separate dataset repositories, each a YOLO-layout dataset directory (images/, labels/, split lists train.txt / val.txt / test.txt):
| dataset | repository | pages |
|---|---|---|
| D4LA | juliozhao/D4LA | 22,184 |
| M6Doc | juliozhao/M6Doc | 17,252 |
| HJDataset | juliozhao/HJDataset | 4,012 |
| PRIMA-LAD | juliozhao/PRIMA-LAD | 956 |
Download
# pip install huggingface_hub
from huggingface_hub import snapshot_download
for repo, local in [
("juliozhao/D4LA", "D4LA"), # keep these exact directory names
("juliozhao/M6Doc", "m6doc"), # (the val/train scripts depend on them)
("juliozhao/HJDataset", "HJDataset"),
("juliozhao/PRIMA-LAD", "prima-lad"),
]:
snapshot_download(repo, repo_type="dataset", local_dir=local)
Each repository is ready to use as-is: the split lists point to the actual file locations, so no post-processing is needed after download.
Usage
The val.py / train.py scripts referenced below ship in the release package. Typical flows:
Validation (dataset root = the parent directory holding the four dataset folders):
python val.py --model downstream/PRIMA-LAD/s_DocLayout-YOLO.pt \
--data prima-lad --dataset-root /absolute/path/to/datasets
--data accepts one of the dataset aliases d4la | m6doc | hjdataset | prima-lad.
Fine-tuning from a pretrained checkpoint:
python train.py --data ultralytics/cfg/datasets/D4LA.yaml \
--pretrain DocLayout-YOLO-pretrain-X.pt \
--epoch 500 --image-size 1600 --batch-size 64 --project runs
Prediction:
from ultralytics import YOLO
model = YOLO("downstream/M6Doc/m_DocLayout-YOLO.pt")
results = model.predict("page.png", imgsz=1600, conf=0.25, device="cuda:0")
results[0].save(filename="result.jpg")
SHA256 (first 16 hex chars)
| repo path | sha256 (16) | size (MB) |
|---|---|---|
DocLayout-YOLO-pretrain-N.pt |
178a9ff51e3cd848 |
9.6 |
DocLayout-YOLO-pretrain-S.pt |
f203c9d02740a549 |
35.8 |
DocLayout-YOLO-pretrain-M.pt |
bfbec6286ef2f659 |
79.3 |
DocLayout-YOLO-pretrain-L.pt |
da336fad052f7ff2 |
107.0 |
DocLayout-YOLO-pretrain-X.pt |
fe0d4daef3d14c8a |
238.6 |
downstream/D4LA/n_DocLayout-YOLO.pt |
ddc1189beed91e27 |
5.0 |
downstream/D4LA/s_DocLayout-YOLO.pt |
a1d0f8efe22580f3 |
18.2 |
downstream/D4LA/m_DocLayout-YOLO.pt |
ecff5e042e03626b |
39.9 |
downstream/D4LA/l_DocLayout-YOLO.pt |
826ec4281d1064a2 |
53.9 |
downstream/D4LA/x_DocLayout-YOLO.pt |
fa1d38605ee26115 |
119.8 |
downstream/M6Doc/n_DocLayout-YOLO.pt |
62e3c9352a050769 |
5.0 |
downstream/M6Doc/s_DocLayout-YOLO.pt |
7ce579090a2a0d51 |
18.1 |
downstream/M6Doc/m_DocLayout-YOLO.pt |
e0b3f0356ed4bb6e |
40.0 |
downstream/M6Doc/l_DocLayout-YOLO.pt |
f4cf7b8e56978ade |
53.9 |
downstream/M6Doc/x_DocLayout-YOLO.pt |
bddd9e3ebb10a412 |
119.8 |
downstream/HJDataset/n_DocLayout-YOLO.pt |
1099870f0b82c01f |
5.0 |
downstream/HJDataset/s_DocLayout-YOLO.pt |
6044020c8f13d5de |
18.2 |
downstream/HJDataset/m_DocLayout-YOLO.pt |
65cf6375760cb08b |
39.9 |
downstream/HJDataset/l_DocLayout-YOLO.pt |
5878bc467353c810 |
53.9 |
downstream/HJDataset/x_DocLayout-YOLO.pt |
7dd575f4115537ea |
119.7 |
downstream/PRIMA-LAD/n_DocLayout-YOLO.pt |
f21f9a798a021374 |
5.0 |
downstream/PRIMA-LAD/s_DocLayout-YOLO.pt |
4e9177b75a3c825c |
18.2 |
downstream/PRIMA-LAD/m_DocLayout-YOLO.pt |
1fcccb0f9273d83a |
39.9 |
downstream/PRIMA-LAD/l_DocLayout-YOLO.pt |
38fb188c3567d033 |
53.9 |
downstream/PRIMA-LAD/x_DocLayout-YOLO.pt |
d79b8c6f9af4e47a |
119.7 |
universal/DocLayout-YOLO-universal.pt |
5c733afe7481aea1 |
119.6 |
License
The source code is distributed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Citation
@misc{zhao2024doclayoutyoloenhancingdocumentlayout,
title={DocLayout-YOLO: Enhancing Document Layout Analysis through Diverse Synthetic Data and Global-to-Local Adaptive Perception},
author={Zhiyuan Zhao and Hengrui Kang and Bin Wang and Conghui He},
year={2024},
eprint={2410.12628},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2410.12628},
}
- Downloads last month
- 672