Instructions to use lucacasarotti/pp-doclayoutv3-ladas with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lucacasarotti/pp-doclayoutv3-ladas with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="lucacasarotti/pp-doclayoutv3-ladas")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForObjectDetection processor = AutoImageProcessor.from_pretrained("lucacasarotti/pp-doclayoutv3-ladas") model = AutoModelForObjectDetection.from_pretrained("lucacasarotti/pp-doclayoutv3-ladas", device_map="auto") - Notebooks
- Google Colab
- Kaggle
PP-DocLayoutV3 fine-tuned on LADaS 2.0
PP-DocLayoutV3 fine-tuned on LADaS to better detect headings, running heads, page numbers and index entries in printed books, while keeping one region per footnote.
It is the layout model of FluxOCR, a GPL-3.0 suite that turns scanned books (mostly humanities and legal history, 17th–21st century print) into accessible HTML, EPUB, tagged PDF and DAISY. FluxOCR uses it next to Marker/Surya: Marker reads the text, this model tells which blocks are footnotes (one per note), so notes can be linked to their call marks.
Same architecture, the same 25 classes and the same processor as the base model: it loads and runs
exactly like PP-DocLayoutV3 in transformers.
import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForObjectDetection
repo = "lucacasarotti/pp-doclayoutv3-ladas"
processor = AutoImageProcessor.from_pretrained(repo)
model = AutoModelForObjectDetection.from_pretrained(repo).eval()
image = Image.open("page.png").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
result = processor.post_process_object_detection(outputs, target_sizes=[image.size[::-1]], threshold=0.5)[0]
for score, label, box in zip(result["scores"], result["labels"], result["boxes"]):
print(model.config.id2label[int(label)], round(float(score), 2), [round(float(v)) for v in box])
The model does no non-maximum suppression across classes: occasionally the same box comes out twice
with two labels (e.g. footnote and reference_content). Drop a region whose IoU with a
higher-scoring region exceeds 0.8.
Training
- Data: LADaS as published on the Hub (4,937 train / 749 validation / 373 test pages), its
SegmOnto classes mapped to the 25 PP-DocLayoutV3 classes:
MainZone-Head→paragraph_title,MainZone-Entry→reference_content,RunningTitleZone→header,NumberingZone→number, paragraphs, lists, verse and speech →text, index title pages →content. - Footnotes: LADaS draws a single box around all the notes of a page. Inside that box the
base model's own regions were used as targets, all relabelled
footnote, so the fine-tuned model keeps one region per note (943 note boxes split into 1,292 notes; 236 kept whole where the base model covered less than 40% of the box). - Stamps, drop capitals, decorations and title pages: pseudo-labels from the base model.
- RT-DETR loss on the detection head; mask and reading-order heads and BatchNorm frozen; lr 2e-5 (backbone ×0.1), batch 4, 8 epochs, best epoch 8. One RTX 5070 Laptop (8 GB), ~18 min/epoch.
Evaluation
LADaS test set (373 pages; F1 at IoU ≥ 0.5, score ≥ 0.5):
| class | base | this model |
|---|---|---|
| text | 0.64 | 0.83 |
| paragraph_title | 0.60 | 0.84 |
| footnote | 0.81 | 0.81 |
| header | 0.66 | 0.92 |
| number | 0.33 | 0.91 |
| reference_content | 0.39 | 0.91 |
| mean | 0.574 | 0.871 |
The footnote score does not move because the footnote targets largely come from the base model.
Books outside LADaS (32 hand-checked pages from four Italian books, from 19th-century lead type to recent print; role of each text line):
- footnotes: every one of the 84 notes in its own region, no note merged with another;
- headings (19 of these pages, 37 headings): recall 0.84 against 0.62 for the base model, at precision 0.78 vs 0.85; the false positives are mostly table-of-contents lines.
Limitations
- Reading order: the reading-order head was frozen, but the fine-tuned model no longer frames two-column lists (indexes) as columns, and its order then interleaves the two columns row by row. Take the order from the base model, or from your OCR.
- Index pages: whole index pages are often one
table/reference_contentregion instead of one region per entry; dash-led indexes can be read astext. - Trained mostly on French and European print; tested on Italian. No handwriting.
License and attribution
Apache-2.0, like the base model. The training data, LADaS, is CC-BY-4.0:
@misc{Clerice_Layout_Analysis_Dataset,
author = {Clérice, Thibault and Janès, Juliette and Scheithauer, Hugo and Bénière, Sarah and Bougrelle, Roxane and Romary, Laurent and Sagot, Benoit},
title = {{Layout Analysis Dataset with SegmOnto (LADaS)}},
url = {https://github.com/DEFI-COLaF/LADaS}
}
Base model: PaddlePaddle, PP-DocLayoutV3, Apache-2.0.
- Downloads last month
- 21
Model tree for lucacasarotti/pp-doclayoutv3-ladas
Base model
PaddlePaddle/PP-DocLayoutV3