Commit ·
3b8fdc3
0
Parent(s):
Duplicate from docling-project/docling-layout-heron
Browse filesCo-authored-by: Nikos Livathinos <nlivathinos@users.noreply.huggingface.co>
- .gitattributes +35 -0
- README.md +110 -0
- config.json +155 -0
- docling_heron_400.png +0 -0
- model.safetensors +3 -0
- preprocessor_config.json +26 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+

|
| 6 |
+
|
| 7 |
+
# Document Layout Analysis "heron"
|
| 8 |
+
|
| 9 |
+
🚀 **`heron`** is the **default layout analysis model** of the [Docling project](https://github.com/docling-project/docling), designed for robust and high-quality document layout understanding.
|
| 10 |
+
|
| 11 |
+
📄 For an in-depth description of the model architecture, training datasets, and evaluation methodology, please refer to our technical report: **"Advanced Layout Analysis Models for Docling"**, Nikolaos Livathinos *et al.*,
|
| 12 |
+
[🔗 https://arxiv.org/abs/2509.11720](https://arxiv.org/abs/2509.11720)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
## Inference code example
|
| 17 |
+
|
| 18 |
+
Prerequisites:
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
pip install transformers Pillow torch requests
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
Prediction:
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
import requests
|
| 28 |
+
from transformers import RTDetrV2ForObjectDetection, RTDetrImageProcessor
|
| 29 |
+
import torch
|
| 30 |
+
from PIL import Image
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
classes_map = {
|
| 34 |
+
0: "Caption",
|
| 35 |
+
1: "Footnote",
|
| 36 |
+
2: "Formula",
|
| 37 |
+
3: "List-item",
|
| 38 |
+
4: "Page-footer",
|
| 39 |
+
5: "Page-header",
|
| 40 |
+
6: "Picture",
|
| 41 |
+
7: "Section-header",
|
| 42 |
+
8: "Table",
|
| 43 |
+
9: "Text",
|
| 44 |
+
10: "Title",
|
| 45 |
+
11: "Document Index",
|
| 46 |
+
12: "Code",
|
| 47 |
+
13: "Checkbox-Selected",
|
| 48 |
+
14: "Checkbox-Unselected",
|
| 49 |
+
15: "Form",
|
| 50 |
+
16: "Key-Value Region",
|
| 51 |
+
}
|
| 52 |
+
image_url = "https://huggingface.co/spaces/ds4sd/SmolDocling-256M-Demo/resolve/main/example_images/annual_rep_14.png"
|
| 53 |
+
model_name = "docling-project/docling-layout-heron"
|
| 54 |
+
threshold = 0.6
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
# Download the image
|
| 58 |
+
image = Image.open(requests.get(image_url, stream=True).raw)
|
| 59 |
+
image = image.convert("RGB")
|
| 60 |
+
|
| 61 |
+
# Initialize the model
|
| 62 |
+
image_processor = RTDetrImageProcessor.from_pretrained(model_name)
|
| 63 |
+
model = RTDetrV2ForObjectDetection.from_pretrained(model_name)
|
| 64 |
+
|
| 65 |
+
# Run the prediction pipeline
|
| 66 |
+
inputs = image_processor(images=[image], return_tensors="pt")
|
| 67 |
+
with torch.no_grad():
|
| 68 |
+
outputs = model(**inputs)
|
| 69 |
+
results = image_processor.post_process_object_detection(
|
| 70 |
+
outputs,
|
| 71 |
+
target_sizes=torch.tensor([image.size[::-1]]),
|
| 72 |
+
threshold=threshold,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
# Get the results
|
| 76 |
+
for result in results:
|
| 77 |
+
for score, label_id, box in zip(
|
| 78 |
+
result["scores"], result["labels"], result["boxes"]
|
| 79 |
+
):
|
| 80 |
+
score = round(score.item(), 2)
|
| 81 |
+
label = classes_map[label_id.item()]
|
| 82 |
+
box = [round(i, 2) for i in box.tolist()]
|
| 83 |
+
print(f"{label}:{score} {box}")
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
## References
|
| 88 |
+
|
| 89 |
+
```
|
| 90 |
+
@misc{livathinos2025advancedlayoutanalysismodels,
|
| 91 |
+
title={advanced layout analysis models for docling},
|
| 92 |
+
author={nikolaos livathinos and christoph auer and ahmed nassar and rafael teixeira de lima and maksym lysak and brown ebouky and cesar berrospi and michele dolfi and panagiotis vagenas and matteo omenetti and kasper dinkla and yusik kim and valery weber and lucas morin and ingmar meijer and viktor kuropiatnyk and tim strohmeyer and a. said gurbuz and peter w. j. staar},
|
| 93 |
+
year={2025},
|
| 94 |
+
eprint={2509.11720},
|
| 95 |
+
archiveprefix={arxiv},
|
| 96 |
+
primaryclass={cs.cv},
|
| 97 |
+
url={https://arxiv.org/abs/2509.11720},
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
@techreport{Docling,
|
| 101 |
+
author = {Deep Search Team},
|
| 102 |
+
month = {8},
|
| 103 |
+
title = {Docling Technical Report},
|
| 104 |
+
url = {https://arxiv.org/abs/2408.09869v4},
|
| 105 |
+
eprint = {2408.09869},
|
| 106 |
+
doi = {10.48550/arXiv.2408.09869},
|
| 107 |
+
version = {1.0.0},
|
| 108 |
+
year = {2024}
|
| 109 |
+
}
|
| 110 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_dropout": 0.0,
|
| 3 |
+
"activation_function": "silu",
|
| 4 |
+
"anchor_image_size": null,
|
| 5 |
+
"architectures": [
|
| 6 |
+
"RTDetrV2ForObjectDetection"
|
| 7 |
+
],
|
| 8 |
+
"attention_dropout": 0.0,
|
| 9 |
+
"auxiliary_loss": true,
|
| 10 |
+
"backbone": null,
|
| 11 |
+
"backbone_config": {
|
| 12 |
+
"depths": [
|
| 13 |
+
3,
|
| 14 |
+
4,
|
| 15 |
+
6,
|
| 16 |
+
3
|
| 17 |
+
],
|
| 18 |
+
"downsample_in_bottleneck": false,
|
| 19 |
+
"downsample_in_first_stage": false,
|
| 20 |
+
"embedding_size": 64,
|
| 21 |
+
"hidden_act": "relu",
|
| 22 |
+
"hidden_sizes": [
|
| 23 |
+
256,
|
| 24 |
+
512,
|
| 25 |
+
1024,
|
| 26 |
+
2048
|
| 27 |
+
],
|
| 28 |
+
"layer_type": "bottleneck",
|
| 29 |
+
"model_type": "rt_detr_resnet",
|
| 30 |
+
"num_channels": 3,
|
| 31 |
+
"out_features": [
|
| 32 |
+
"stage2",
|
| 33 |
+
"stage3",
|
| 34 |
+
"stage4"
|
| 35 |
+
],
|
| 36 |
+
"out_indices": [
|
| 37 |
+
2,
|
| 38 |
+
3,
|
| 39 |
+
4
|
| 40 |
+
],
|
| 41 |
+
"stage_names": [
|
| 42 |
+
"stem",
|
| 43 |
+
"stage1",
|
| 44 |
+
"stage2",
|
| 45 |
+
"stage3",
|
| 46 |
+
"stage4"
|
| 47 |
+
]
|
| 48 |
+
},
|
| 49 |
+
"backbone_kwargs": null,
|
| 50 |
+
"batch_norm_eps": 1e-05,
|
| 51 |
+
"box_noise_scale": 1.0,
|
| 52 |
+
"d_model": 256,
|
| 53 |
+
"decoder_activation_function": "relu",
|
| 54 |
+
"decoder_attention_heads": 8,
|
| 55 |
+
"decoder_ffn_dim": 1024,
|
| 56 |
+
"decoder_in_channels": [
|
| 57 |
+
256,
|
| 58 |
+
256,
|
| 59 |
+
256
|
| 60 |
+
],
|
| 61 |
+
"decoder_layers": 6,
|
| 62 |
+
"decoder_method": "default",
|
| 63 |
+
"decoder_n_levels": 3,
|
| 64 |
+
"decoder_n_points": 4,
|
| 65 |
+
"decoder_offset_scale": 0.5,
|
| 66 |
+
"dropout": 0.0,
|
| 67 |
+
"encode_proj_layers": [
|
| 68 |
+
2
|
| 69 |
+
],
|
| 70 |
+
"encoder_activation_function": "gelu",
|
| 71 |
+
"encoder_attention_heads": 8,
|
| 72 |
+
"encoder_ffn_dim": 1024,
|
| 73 |
+
"encoder_hidden_dim": 256,
|
| 74 |
+
"encoder_in_channels": [
|
| 75 |
+
512,
|
| 76 |
+
1024,
|
| 77 |
+
2048
|
| 78 |
+
],
|
| 79 |
+
"encoder_layers": 1,
|
| 80 |
+
"eos_coefficient": 0.0001,
|
| 81 |
+
"eval_size": null,
|
| 82 |
+
"feat_strides": [
|
| 83 |
+
8,
|
| 84 |
+
16,
|
| 85 |
+
32
|
| 86 |
+
],
|
| 87 |
+
"focal_loss_alpha": 0.75,
|
| 88 |
+
"focal_loss_gamma": 2.0,
|
| 89 |
+
"freeze_backbone_batch_norms": true,
|
| 90 |
+
"hidden_expansion": 1.0,
|
| 91 |
+
"id2label": {
|
| 92 |
+
"0": "caption",
|
| 93 |
+
"1": "footnote",
|
| 94 |
+
"2": "formula",
|
| 95 |
+
"3": "list_item",
|
| 96 |
+
"4": "page_footer",
|
| 97 |
+
"5": "page_header",
|
| 98 |
+
"6": "picture",
|
| 99 |
+
"7": "section_header",
|
| 100 |
+
"8": "table",
|
| 101 |
+
"9": "text",
|
| 102 |
+
"10": "title",
|
| 103 |
+
"11": "document_index",
|
| 104 |
+
"12": "code",
|
| 105 |
+
"13": "checkbox_selected",
|
| 106 |
+
"14": "checkbox_unselected",
|
| 107 |
+
"15": "form",
|
| 108 |
+
"16": "key_value_region"
|
| 109 |
+
},
|
| 110 |
+
"initializer_bias_prior_prob": null,
|
| 111 |
+
"initializer_range": 0.01,
|
| 112 |
+
"is_encoder_decoder": true,
|
| 113 |
+
"label2id": {
|
| 114 |
+
"caption": 0,
|
| 115 |
+
"checkbox_selected": 13,
|
| 116 |
+
"checkbox_unselected": 14,
|
| 117 |
+
"code": 12,
|
| 118 |
+
"document_index": 11,
|
| 119 |
+
"footnote": 1,
|
| 120 |
+
"form": 15,
|
| 121 |
+
"formula": 2,
|
| 122 |
+
"key_value_region": 16,
|
| 123 |
+
"list_item": 3,
|
| 124 |
+
"page_footer": 4,
|
| 125 |
+
"page_header": 5,
|
| 126 |
+
"picture": 6,
|
| 127 |
+
"section_header": 7,
|
| 128 |
+
"table": 8,
|
| 129 |
+
"text": 9,
|
| 130 |
+
"title": 10
|
| 131 |
+
},
|
| 132 |
+
"label_noise_ratio": 0.5,
|
| 133 |
+
"layer_norm_eps": 1e-05,
|
| 134 |
+
"learn_initial_query": false,
|
| 135 |
+
"matcher_alpha": 0.25,
|
| 136 |
+
"matcher_bbox_cost": 5.0,
|
| 137 |
+
"matcher_class_cost": 2.0,
|
| 138 |
+
"matcher_gamma": 2.0,
|
| 139 |
+
"matcher_giou_cost": 2.0,
|
| 140 |
+
"model_type": "rt_detr_v2",
|
| 141 |
+
"normalize_before": false,
|
| 142 |
+
"num_denoising": 100,
|
| 143 |
+
"num_feature_levels": 3,
|
| 144 |
+
"num_queries": 300,
|
| 145 |
+
"positional_encoding_temperature": 10000,
|
| 146 |
+
"torch_dtype": "float32",
|
| 147 |
+
"transformers_version": "4.53.0.dev0",
|
| 148 |
+
"use_focal_loss": true,
|
| 149 |
+
"use_pretrained_backbone": false,
|
| 150 |
+
"use_timm_backbone": false,
|
| 151 |
+
"weight_loss_bbox": 5.0,
|
| 152 |
+
"weight_loss_giou": 2.0,
|
| 153 |
+
"weight_loss_vfl": 1.0,
|
| 154 |
+
"with_box_refine": true
|
| 155 |
+
}
|
docling_heron_400.png
ADDED
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00333a43451945aaf89db8ca9c0a17e75d1537c17db60fdb91aa95f4c7929e0c
|
| 3 |
+
size 171658996
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_convert_annotations": true,
|
| 3 |
+
"do_normalize": false,
|
| 4 |
+
"do_pad": false,
|
| 5 |
+
"do_rescale": true,
|
| 6 |
+
"do_resize": true,
|
| 7 |
+
"format": "coco_detection",
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.485,
|
| 10 |
+
0.456,
|
| 11 |
+
0.406
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "RTDetrImageProcessor",
|
| 14 |
+
"image_std": [
|
| 15 |
+
0.229,
|
| 16 |
+
0.224,
|
| 17 |
+
0.225
|
| 18 |
+
],
|
| 19 |
+
"pad_size": null,
|
| 20 |
+
"resample": 2,
|
| 21 |
+
"rescale_factor": 0.00392156862745098,
|
| 22 |
+
"size": {
|
| 23 |
+
"height": 640,
|
| 24 |
+
"width": 640
|
| 25 |
+
}
|
| 26 |
+
}
|