AvoCahDoe commited on
Commit
cf20976
·
verified ·
1 Parent(s): c55c03a

Upload YOLO11m invoice layout model with metrics and visualizations

Browse files
Files changed (1) hide show
  1. README.md +171 -8
README.md CHANGED
@@ -1,32 +1,195 @@
1
  ---
2
  license: apache-2.0
 
 
 
3
  tags:
4
  - object-detection
5
  - yolo
 
 
6
  - invoice
7
  - document-layout
 
 
 
8
  library_name: ultralytics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
- # Invoice Layout — yolo11m
12
 
13
- Fine-tuned yolo11m for invoice macro-region detection (8 classes).
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  ## Classes
16
 
17
- `invoice_metadata`, `vendor_block`, `customer_block`, `table_block`, `line_item`, `summary_block`, `payment_block`, `Column`
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- ## Metrics (test split)
20
 
21
  | Metric | Value |
22
  |--------|-------|
23
- | mAP50 | 0.8418 |
24
- | mAP50-95 | 0.4926 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  ## Usage
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ```python
29
  from ultralytics import YOLO
30
- model = YOLO("best.pt")
31
- results = model.predict("invoice.png")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ - de
6
  tags:
7
  - object-detection
8
  - yolo
9
+ - yolo11
10
+ - ultralytics
11
  - invoice
12
  - document-layout
13
+ - document-understanding
14
+ - ocr-prep
15
+ - invoice-extraction
16
  library_name: ultralytics
17
+ pipeline_tag: object-detection
18
+ base_model: ultralytics/yolo11m
19
+ datasets:
20
+ - AvoCahDoe/invoice-annotated-bbox
21
+ metrics:
22
+ - map_50
23
+ - map
24
+ - precision
25
+ - recall
26
+ model-index:
27
+ - name: best
28
+ results:
29
+ - task:
30
+ type: object-detection
31
+ dataset:
32
+ name: invoice-yolo-annotated
33
+ type: invoice-layout
34
+ metrics:
35
+ - type: map_50
36
+ value: 0.8418
37
+ - type: map
38
+ value: 0.4926
39
+ - type: precision
40
+ value: 0.9033
41
+ - type: recall
42
+ value: 0.8466
43
  ---
44
 
45
+ # Invoice Layout Detection — YOLO11m
46
 
47
+ Fine-tuned **YOLO11m** for **8-class invoice document layout** region detection (metadata, vendor/customer blocks, table, line items, summary, payment, column headers).
48
+
49
+ | Property | Value |
50
+ |----------|-------|
51
+ | **Architecture** | YOLO11m (20.1M params, 68.0 GFLOPs) |
52
+ | **Base weights** | `ultralytics/yolo11m` |
53
+ | **Input size** | 1024 px |
54
+ | **Classes** | 8 layout regions |
55
+ | **Training epochs** | 100 (best @ epoch 91) |
56
+ | **Optimizer** | AdamW |
57
+ | **Dataset** | [AvoCahDoe/invoice-annotated-bbox](https://huggingface.co/datasets/AvoCahDoe/invoice-annotated-bbox) |
58
+ | **Demo Space** | [AvoCahDoe/invoice-layout-yolov8n-demo](https://huggingface.co/spaces/AvoCahDoe/invoice-layout-yolov8n-demo) |
59
+ | **Train / val / test** | 372 / 14 / 7 pages |
60
 
61
  ## Classes
62
 
63
+ | ID | Name |
64
+ |----|------|
65
+ | 0 | `invoice_metadata` |
66
+ | 1 | `vendor_block` |
67
+ | 2 | `customer_block` |
68
+ | 3 | `table_block` |
69
+ | 4 | `line_item` |
70
+ | 5 | `summary_block` |
71
+ | 6 | `payment_block` |
72
+ | 7 | `Column` |
73
+
74
+ ## Metrics
75
 
76
+ ### Test split (held-out, 7 images)
77
 
78
  | Metric | Value |
79
  |--------|-------|
80
+ | **mAP50** | 0.8418 |
81
+ | **mAP50-95** | 0.4926 |
82
+ | **Precision** | 0.9033 |
83
+ | **Recall** | 0.8466 |
84
+
85
+ ### Validation (best epoch 91)
86
+
87
+ | Metric | Best | Final (epoch 100) |
88
+ |--------|------|-----------------------------------------------|
89
+ | mAP50 | 0.8493 | 0.8780 |
90
+ | mAP50-95 | 0.4951 | 0.4917 |
91
+ | Precision | 0.8280 | 0.8682 |
92
+ | Recall | 0.7991 | 0.7980 |
93
+
94
+ Training time: ~180.4 min on RTX 4070 Laptop GPU.
95
+
96
+ ## Training configuration
97
+
98
+ | Parameter | Value |
99
+ |-----------|-------|
100
+ | Batch | 6 |
101
+ | Image size | 1024 |
102
+ | Patience | 25 |
103
+ | LR (cosine) | 0.01 → 0.01 |
104
+ | Mosaic | 1.0 |
105
+ | Mixup | 0.15 |
106
+ | Copy-paste | 0.1 |
107
+ | Horizontal flip | 0.0 |
108
+
109
+ ## Training results
110
+
111
+ ### Learning curves
112
+
113
+ ![Training results](assets/results.png)
114
+
115
+ ### Precision–Recall
116
+
117
+ ![PR curve](assets/BoxPR_curve.png)
118
+
119
+ ### Confusion matrices
120
+
121
+ | Raw | Normalized |
122
+ |-----|------------|
123
+ | ![Confusion matrix](assets/confusion_matrix.png) | ![Normalized confusion matrix](assets/confusion_matrix_normalized.png) |
124
+
125
+ ### Validation predictions
126
+
127
+ | Ground truth | Model predictions |
128
+ |--------------|-------------------|
129
+ | ![Val labels](assets/val_batch0_labels.jpg) | ![Val predictions](assets/val_batch0_pred.jpg) |
130
+
131
+ ### Training batches (augmented)
132
+
133
+ | Batch 0 | Batch 1 | Batch 2 |
134
+ |---------|---------|---------|
135
+ | ![Train batch 0](assets/train_batch0.jpg) | ![Train batch 1](assets/train_batch1.jpg) | ![Train batch 2](assets/train_batch2.jpg) |
136
+
137
+ ### Label distribution
138
+
139
+ ![Label distribution](assets/labels.jpg)
140
 
141
  ## Usage
142
 
143
+ ### Ultralytics (recommended)
144
+
145
+ ```python
146
+ from ultralytics import YOLO
147
+ from huggingface_hub import hf_hub_download
148
+
149
+ weights = hf_hub_download("AvoCahDoe/invoice-layout-yolo11m", "weights/best.pt")
150
+ model = YOLO(weights)
151
+ results = model.predict("invoice_page.png", imgsz=1024, conf=0.25)
152
+ results[0].show()
153
+ ```
154
+
155
+ ### Load from Hub by repo id
156
+
157
  ```python
158
  from ultralytics import YOLO
159
+
160
+ model = YOLO("hf://AvoCahDoe/invoice-layout-yolo11m/weights/best.pt")
161
+ results = model.predict("invoice_page.png")
162
+ ```
163
+
164
+ ### Training reproduction
165
+
166
+ ```bash
167
+ python scripts/train_comparison.py --models yolo11m
168
+ ```
169
+
170
+ ## Repository layout
171
+
172
+ ```
173
+ weights/best.pt # Best checkpoint (use this)
174
+ weights/last.pt # Last epoch checkpoint
175
+ config/ # Training configuration
176
+ metrics/ # Per-epoch and summary metrics
177
+ assets/ # Plots and visualizations
178
  ```
179
+
180
+ ## Model comparison (test split)
181
+
182
+ All six architectures fine-tuned on the same invoice layout dataset.
183
+
184
+ | Rank | Model | test mAP50 | test mAP50-95 | Precision | Recall | Hub |
185
+ |------|-------|------------|---------------|-----------|--------|-----|
186
+ | 1 | `yolov8n` | 0.9600 | 0.7167 | 0.9502 | 0.9592 | [YOLOv8n](https://huggingface.co/AvoCahDoe/invoice-layout-yolov8n) |
187
+ | 2 | `yolov8s` | 0.9006 | 0.6739 | 0.9419 | 0.8677 | [YOLOv8s](https://huggingface.co/AvoCahDoe/invoice-layout-yolov8s) |
188
+ | 3 | `yolov8x` | 0.8757 | 0.6224 | 0.9144 | 0.8735 | [YOLOv8x](https://huggingface.co/AvoCahDoe/invoice-layout-yolov8x) |
189
+ | 4 | `yolo11x` | 0.8738 | 0.6127 | 0.9484 | 0.8530 | [YOLO11x](https://huggingface.co/AvoCahDoe/invoice-layout-yolo11x) |
190
+ | 5 | `yolo11m` **← this model** | 0.8418 | 0.4926 | 0.9033 | 0.8466 | [YOLO11m](https://huggingface.co/AvoCahDoe/invoice-layout-yolo11m) |
191
+ | 6 | `yolov8m` | 0.8388 | 0.5289 | 0.9077 | 0.8580 | [YOLOv8m](https://huggingface.co/AvoCahDoe/invoice-layout-yolov8m) |
192
+
193
+ ## License
194
+
195
+ Apache 2.0