albertosei commited on
Commit
d7b27c7
·
verified ·
1 Parent(s): 29e87a4

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +134 -0
README.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ task_categories:
3
+ - token-classification
4
+ - image-to-text
5
+ - object-detection
6
+ tags:
7
+ - invoices
8
+ - finance
9
+ - document-understanding
10
+ - layoutlm
11
+ - ner
12
+ features:
13
+ id:
14
+ dtype: int32
15
+ words:
16
+ dtype: string
17
+ sequence: string
18
+ boxes:
19
+ dtype: int64
20
+ sequence:
21
+ sequence: int64
22
+ ner_tags:
23
+ class_label:
24
+ names:
25
+ 0: O
26
+ 1: B-BALANCE_DUE
27
+ 2: B-BANK_NAME
28
+ 3: B-CLIENT_ADDRESS
29
+ 4: B-CLIENT_EMAIL
30
+ 5: B-CLIENT_NAME
31
+ 6: B-CLIENT_PHONE
32
+ 7: B-CLIENT_TAX_ID
33
+ 8: B-CURRENCY
34
+ 9: B-DUE_DATE
35
+ 10: B-IBAN
36
+ 11: B-INVOICE_DATE
37
+ 12: B-INVOICE_NUMBER
38
+ 13: B-ITEM_DESC
39
+ 14: B-ITEM_NO
40
+ 15: B-LINE_DISCOUNT
41
+ 16: B-LINE_GROSS_WORTH
42
+ 17: B-LINE_NET_WORTH
43
+ 18: B-LINE_UNIT_PRICE
44
+ 19: B-LINE_VAT
45
+ 20: B-ORDER_NUMBER
46
+ 21: B-QTY
47
+ 22: B-REFERENCE_NUMBER
48
+ 23: B-SELLER_ADDRESS
49
+ 24: B-SELLER_EMAIL
50
+ 25: B-SELLER_NAME
51
+ 26: B-SELLER_PHONE
52
+ 27: B-SELLER_TAX_ID
53
+ 28: B-SUBTOTAL
54
+ 29: B-TOTAL_GROSS_WORTH
55
+ 30: B-TOTAL_NET_WORTH
56
+ 31: B-TOTAL_VAT
57
+ 32: I-BANK_NAME
58
+ 33: I-CLIENT_ADDRESS
59
+ 34: I-CLIENT_EMAIL
60
+ 35: I-CLIENT_NAME
61
+ 36: I-CLIENT_PHONE
62
+ 37: I-INVOICE_NUMBER
63
+ 38: I-ITEM_DESC
64
+ 39: I-LINE_NET_WORTH
65
+ 40: I-LINE_UNIT_PRICE
66
+ 41: I-SELLER_ADDRESS
67
+ 42: I-SELLER_EMAIL
68
+ 43: I-SELLER_NAME
69
+ 44: I-SELLER_PHONE
70
+ 45: I-SELLER_TAX_ID
71
+ 46: I-TOTAL_NET_WORTH
72
+ image:
73
+ dtype: image
74
+ ---
75
+
76
+ # Merged Invoice NER Dataset
77
+
78
+ ## Dataset Description
79
+
80
+ This dataset consists of processed invoice documents intended for **Document Layout Analysis** and **Named Entity Recognition (NER)** tasks (e.g., training LayoutLM, LayoutLMv2, LayoutLMv3, or LiLT).
81
+
82
+ The data was created by merging multiple invoice datasets. It includes the document images, OCR-extracted words, bounding boxes, and NER tags.
83
+
84
+ ### Supported Tasks
85
+ - **Token Classification:** Extracting entities like `INVOICE_NUMBER`, `TOTAL_GROSS_WORTH`, `SELLER_NAME`, etc.
86
+ - **Key Information Extraction (KIE)**
87
+
88
+ ## Data Structure
89
+
90
+ Each example in the dataset contains the following fields:
91
+
92
+ - **`id`**: A unique identifier for the document.
93
+ - **`image`**: The PIL Image of the invoice.
94
+ - **`words`**: List of strings (tokens) obtained via OCR.
95
+ - **`boxes`**: List of bounding boxes corresponding to the words.
96
+ - **Format:** `[x_min, y_min, x_max, y_max]`
97
+ - **Note:** These boxes are likely in **absolute pixel coordinates** (based on the image size) and **NOT normalized** to 0-1000. You must normalize them before inputting them into models like LayoutLM.
98
+ - **`ner_tags`**: List of class IDs (integers) in BIO (Beginning, Inside, Outside) format.
99
+
100
+ ## Important Usage Warnings
101
+
102
+ ### 1. Bounding Box Normalization Required
103
+ The `boxes` in this dataset are likely stored in absolute pixel values (e.g., `0-2500`). Models like LayoutLM expect boxes normalized to a `0-1000` scale.
104
+
105
+ **How to handle this:**
106
+ When loading the dataset, you should normalize the boxes relative to the image size:
107
+
108
+ ```python
109
+ def normalize_box(box, width, height):
110
+ return [
111
+ int(1000 * (box[0] / width)),
112
+ int(1000 * (box[1] / height)),
113
+ int(1000 * (box[2] / width)),
114
+ int(1000 * (box[3] / height)),
115
+ ]
116
+
117
+ def preprocess(example):
118
+ w, h = example['image'].size
119
+ # Normalize boxes to 0-1000
120
+ example['boxes'] = [normalize_box(box, w, h) for box in example['boxes']]
121
+ return example
122
+
123
+ dataset = load_dataset("your-username/dataset-name")
124
+ dataset = dataset.map(preprocess)
125
+
126
+ 2. Mixed OCR Sources
127
+ This dataset was created by merging sources that may have used different OCR engines (e.g., Tesseract, EasyOCR, or commercial APIs).
128
+ Some documents may have slightly different bounding box tightness or word-splitting logic.
129
+ Ensure your training pipeline is robust to slight variations in OCR quality.
130
+ 3. Missing I-Tags for some entities
131
+ The label map includes B- (Beginning) tags for all entities, but some entities (like BALANCE_DUE, TOTAL_VAT, IBAN) do not have a corresponding I- (Inside) tag in the schema.
132
+ If a value spans multiple words (e.g., "Total VAT"), the model may only be able to label the first word, or you may need to map the subsequent words to O or a generic tag during training.
133
+ 4. Privacy / PII
134
+ This dataset contains invoice data. While processed, users should handle the data with care regarding Personally Identifiable Information (PII) such as names, addresses, and financial details.