selvakumarcts commited on
Commit
2ac4657
1 Parent(s): 56a250f

Upload 10 files

Browse files
README.md ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ Model Architecture:
6
+
7
+ The mychen76/invoice-and-receipts_donut_v1 (LLM) is a finetuned for convert Invoice or Receipt Image to XML or Json data strucutre task. this experimental model is based on Donut model.
8
+
9
+ Motivation:
10
+
11
+ Remove OCR engine, use only LLM model to convert an invoice or receipt json object could reduce the conversion step and reduce resource utilization and deployment dependencies. Result, better performance.
12
+
13
+ Model Usage:
14
+
15
+ Take following an invoice receipt image and get an output Json or xml like this:
16
+
17
+ ***JSON OUTPUT***
18
+ ```json
19
+
20
+ {
21
+ 'header': {
22
+ 'invoice_no': '13194726',
23
+ 'invoice_date': '05/29/2021',
24
+ 'seller': 'Hopkins and Sons 62283 Flores Tunnel North Luis, IA 69983',
25
+ 'client': 'Sims PLC USS Kramer FPO AA 81651',
26
+ 'seller_tax_id': '952-73-7223',
27
+ 'client_tax_id': '995-88-9495',
28
+ 'iban': 'GB31LZX520242755934691'
29
+ },
30
+ 'items': [
31
+ {
32
+ 'item_desc': 'Beach Lunch Lounge Striped Shirt Dress Large Navy Blue White Long Sleeve Casual',
33
+ 'item_qty': '1,00',
34
+ 'item_net_price': '16,99',
35
+ 'item_net_worth': '16,99',
36
+ 'item_vat': '10%',
37
+ 'item_gross_worth': '18,69'
38
+ },
39
+ {
40
+ 'item_desc': 'Jams World Hawaiian 0 Dress Rayon SZ.L',
41
+ 'item_qty': '5,00',
42
+ 'item_net_price': '65,00',
43
+ 'item_net_worth': '325,00',
44
+ 'item_vat': '10%',
45
+ 'item_gross_worth': '357,50'
46
+ },
47
+ {
48
+ 'item_desc': 'LuLaRoe Nicole Dress Size Large 26',
49
+ 'item_qty': '2,00',
50
+ 'item_net_price': '1,99',
51
+ 'item_net_worth': '3,98',
52
+ 'item_vat': '10%',
53
+ 'item_gross_worth': '4,38'
54
+ },
55
+ {
56
+ 'item_desc': 'phynny Was Medium Linen Wrap Dress Dessert Rose Embroidered Bohemian',
57
+ 'item_qty': '2,00',
58
+ 'item_net_price': '89,99',
59
+ 'item_net_worth': '179,98',
60
+ 'item_vat': '10%',
61
+ 'item_gross_worth': '197,98'
62
+ },
63
+ {
64
+ 'item_desc': "Eileen Fisher Women's Long Sleeve Fleece Lined Front Pockets Dress XS Gray",
65
+ 'item_qty': '2,00',
66
+ 'item_net_price': '15,99',
67
+ 'item_net_worth': '31,98',
68
+ 'item_vat': '10%',
69
+ 'item_gross_worth': '35,18'
70
+ },
71
+ {
72
+ 'item_desc': "Hanna Anderson Women's L Large Coral Short Sleeve Casual Fall Tee Shirt Dress",
73
+ 'item_qty': '1,00',
74
+ 'item_net_price': '24,00',
75
+ 'item_net_worth': '24,00',
76
+ 'item_vat': '10%',
77
+ 'item_gross_worth': '26,40'
78
+ }
79
+ ],
80
+ 'summary': {'total_net_worth': '$581,93', 'total_vat': '$58,19', 'total_gross_worth': '$ 640,12'}
81
+ }
82
+
83
+ ```
84
+
85
+ ***XML OUTPUT***
86
+
87
+ ```xml
88
+ <s_header>
89
+ <s_invoice_no> 13194726</s_invoice_no>
90
+ <s_invoice_date> 05/29/2021</s_invoice_date>
91
+ <s_seller> Hopkins and
92
+ Sons 62283 Flores Tunnel North Luis, IA 69983</s_seller>
93
+ <s_client> Sims PLC USS Kramer FPO AA
94
+ 81651</s_client>
95
+ <s_seller_tax_id> 952-73-7223</s_seller_tax_id>
96
+ <s_client_tax_id>
97
+ 995-88-9495</s_client_tax_id>
98
+ <s_iban> GB31LZX520242755934691</s_iban>
99
+ </s_header>
100
+ <s_items>
101
+ <s_item_desc> Beach Lunch
102
+ Lounge Striped Shirt Dress Large Navy Blue White Long Sleeve Casual</s_item_desc>
103
+ <s_item_qty>
104
+ 1,00</s_item_qty>
105
+ <s_item_net_price> 16,99</s_item_net_price>
106
+ <s_item_net_worth> 16,99</s_item_net_worth>
107
+ <s_item_vat>
108
+ 10%</s_item_vat>
109
+ <s_item_gross_worth> 18,69</s_item_gross_worth>
110
+ <sep/>
111
+ <s_item_desc> Jams World Hawaiian 0 Dress
112
+ Rayon SZ.L</s_item_desc>
113
+ <s_item_qty> 5,00</s_item_qty>
114
+ <s_item_net_price> 65,00</s_item_net_price>
115
+ <s_item_net_worth>
116
+ 325,00</s_item_net_worth>
117
+ <s_item_vat> 10%</s_item_vat>
118
+ <s_item_gross_worth>
119
+ 357,50</s_item_gross_worth>
120
+ <sep/>
121
+ <s_item_desc> LuLaRoe Nicole Dress Size Large 26</s_item_desc>
122
+ <s_item_qty>
123
+ 2,00</s_item_qty>
124
+ <s_item_net_price> 1,99</s_item_net_price>
125
+ <s_item_net_worth> 3,98</s_item_net_worth>
126
+ <s_item_vat>
127
+ 10%</s_item_vat>
128
+ <s_item_gross_worth> 4,38</s_item_gross_worth>
129
+ <sep/>
130
+ <s_item_desc> phynny Was Medium Linen Wrap
131
+ Dress Dessert Rose Embroidered Bohemian</s_item_desc>
132
+ <s_item_qty> 2,00</s_item_qty>
133
+ <s_item_net_price>
134
+ 89,99</s_item_net_price>
135
+ <s_item_net_worth> 179,98</s_item_net_worth>
136
+ <s_item_vat>
137
+ 10%</s_item_vat>
138
+ <s_item_gross_worth> 197,98</s_item_gross_worth>
139
+ <sep/>
140
+ <s_item_desc> Eileen Fisher Women's Long
141
+ Sleeve Fleece Lined Front Pockets Dress XS Gray</s_item_desc>
142
+ <s_item_qty> 2,00</s_item_qty>
143
+ <s_item_net_price>
144
+ 15,99</s_item_net_price>
145
+ <s_item_net_worth> 31,98</s_item_net_worth>
146
+ <s_item_vat>
147
+ 10%</s_item_vat>
148
+ <s_item_gross_worth> 35,18</s_item_gross_worth>
149
+ <sep/>
150
+ <s_item_desc> Hanna Anderson Women's L Large
151
+ Coral Short Sleeve Casual Fall Tee Shirt Dress</s_item_desc>
152
+ <s_item_qty> 1,00</s_item_qty>
153
+ <s_item_net_price>
154
+ 24,00</s_item_net_price>
155
+ <s_item_net_worth> 24,00</s_item_net_worth>
156
+ <s_item_vat>
157
+ 10%</s_item_vat>
158
+ <s_item_gross_worth> 26,40</s_item_gross_worth>
159
+ </s_items>
160
+ <s_summary>
161
+ <s_total_net_worth>
162
+ $581,93</s_total_net_worth>
163
+ <s_total_vat> $58,19</s_total_vat>
164
+ <s_total_gross_worth> $
165
+ 640,12</s_total_gross_worth>
166
+ </s_summary>
167
+
168
+ ```
added_tokens.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</s_None>": 57564,
3
+ "</s_client>": 57534,
4
+ "</s_client_tax_id>": 57538,
5
+ "</s_date>": 57572,
6
+ "</s_header>": 57526,
7
+ "</s_iban>": 57540,
8
+ "</s_ignore>": 57582,
9
+ "</s_invoice_date>": 57530,
10
+ "</s_invoice_no>": 57528,
11
+ "</s_item_desc>": 57544,
12
+ "</s_item_gross_worth>": 57554,
13
+ "</s_item_key>": 57588,
14
+ "</s_item_name>": 57590,
15
+ "</s_item_net_price>": 57548,
16
+ "</s_item_net_worth>": 57550,
17
+ "</s_item_qty>": 57546,
18
+ "</s_item_quantity>": 57594,
19
+ "</s_item_value>": 57592,
20
+ "</s_item_vat>": 57552,
21
+ "</s_items>": 57542,
22
+ "</s_line_items>": 57586,
23
+ "</s_seller>": 57532,
24
+ "</s_seller_tax_id>": 57536,
25
+ "</s_store_addr>": 57568,
26
+ "</s_store_name>": 57566,
27
+ "</s_subtotal>": 57576,
28
+ "</s_summary>": 57556,
29
+ "</s_tax>": 57578,
30
+ "</s_telephone>": 57570,
31
+ "</s_time>": 57574,
32
+ "</s_tips>": 57584,
33
+ "</s_total>": 57580,
34
+ "</s_total_gross_worth>": 57562,
35
+ "</s_total_net_worth>": 57558,
36
+ "</s_total_vat>": 57560,
37
+ "<s_None>": 57563,
38
+ "<s_client>": 57533,
39
+ "<s_client_tax_id>": 57537,
40
+ "<s_date>": 57571,
41
+ "<s_header>": 57525,
42
+ "<s_iban>": 57539,
43
+ "<s_ignore>": 57581,
44
+ "<s_iitcdip>": 57523,
45
+ "<s_invoice_date>": 57529,
46
+ "<s_invoice_no>": 57527,
47
+ "<s_item_desc>": 57543,
48
+ "<s_item_gross_worth>": 57553,
49
+ "<s_item_key>": 57587,
50
+ "<s_item_name>": 57589,
51
+ "<s_item_net_price>": 57547,
52
+ "<s_item_net_worth>": 57549,
53
+ "<s_item_qty>": 57545,
54
+ "<s_item_quantity>": 57593,
55
+ "<s_item_value>": 57591,
56
+ "<s_item_vat>": 57551,
57
+ "<s_items>": 57541,
58
+ "<s_line_items>": 57585,
59
+ "<s_receipt>": 57595,
60
+ "<s_seller>": 57531,
61
+ "<s_seller_tax_id>": 57535,
62
+ "<s_store_addr>": 57567,
63
+ "<s_store_name>": 57565,
64
+ "<s_subtotal>": 57575,
65
+ "<s_summary>": 57555,
66
+ "<s_synthdog>": 57524,
67
+ "<s_tax>": 57577,
68
+ "<s_telephone>": 57569,
69
+ "<s_time>": 57573,
70
+ "<s_tips>": 57583,
71
+ "<s_total>": 57579,
72
+ "<s_total_gross_worth>": 57561,
73
+ "<s_total_net_worth>": 57557,
74
+ "<s_total_vat>": 57559,
75
+ "<sep/>": 57522
76
+ }
config.json ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "naver-clova-ix/donut-base",
3
+ "architectures": [
4
+ "VisionEncoderDecoderModel"
5
+ ],
6
+ "decoder": {
7
+ "_name_or_path": "",
8
+ "activation_dropout": 0.0,
9
+ "activation_function": "gelu",
10
+ "add_cross_attention": true,
11
+ "add_final_layer_norm": true,
12
+ "architectures": null,
13
+ "attention_dropout": 0.0,
14
+ "bad_words_ids": null,
15
+ "begin_suppress_tokens": null,
16
+ "bos_token_id": 0,
17
+ "chunk_size_feed_forward": 0,
18
+ "classifier_dropout": 0.0,
19
+ "cross_attention_hidden_size": null,
20
+ "d_model": 1024,
21
+ "decoder_attention_heads": 16,
22
+ "decoder_ffn_dim": 4096,
23
+ "decoder_layerdrop": 0.0,
24
+ "decoder_layers": 4,
25
+ "decoder_start_token_id": null,
26
+ "diversity_penalty": 0.0,
27
+ "do_sample": false,
28
+ "dropout": 0.1,
29
+ "early_stopping": false,
30
+ "encoder_attention_heads": 16,
31
+ "encoder_ffn_dim": 4096,
32
+ "encoder_layerdrop": 0.0,
33
+ "encoder_layers": 12,
34
+ "encoder_no_repeat_ngram_size": 0,
35
+ "eos_token_id": 2,
36
+ "exponential_decay_length_penalty": null,
37
+ "finetuning_task": null,
38
+ "forced_bos_token_id": null,
39
+ "forced_eos_token_id": 2,
40
+ "id2label": {
41
+ "0": "LABEL_0",
42
+ "1": "LABEL_1"
43
+ },
44
+ "init_std": 0.02,
45
+ "is_decoder": true,
46
+ "is_encoder_decoder": false,
47
+ "label2id": {
48
+ "LABEL_0": 0,
49
+ "LABEL_1": 1
50
+ },
51
+ "length_penalty": 1.0,
52
+ "max_length": 768,
53
+ "max_position_embeddings": 1536,
54
+ "min_length": 0,
55
+ "model_type": "mbart",
56
+ "no_repeat_ngram_size": 0,
57
+ "num_beam_groups": 1,
58
+ "num_beams": 1,
59
+ "num_hidden_layers": 12,
60
+ "num_return_sequences": 1,
61
+ "output_attentions": false,
62
+ "output_hidden_states": false,
63
+ "output_scores": false,
64
+ "pad_token_id": 1,
65
+ "prefix": null,
66
+ "problem_type": null,
67
+ "pruned_heads": {},
68
+ "remove_invalid_values": false,
69
+ "repetition_penalty": 1.0,
70
+ "return_dict": true,
71
+ "return_dict_in_generate": false,
72
+ "scale_embedding": true,
73
+ "sep_token_id": null,
74
+ "suppress_tokens": null,
75
+ "task_specific_params": null,
76
+ "temperature": 1.0,
77
+ "tf_legacy_loss": false,
78
+ "tie_encoder_decoder": false,
79
+ "tie_word_embeddings": true,
80
+ "tokenizer_class": null,
81
+ "top_k": 50,
82
+ "top_p": 1.0,
83
+ "torch_dtype": null,
84
+ "torchscript": false,
85
+ "typical_p": 1.0,
86
+ "use_bfloat16": false,
87
+ "use_cache": true,
88
+ "vocab_size": 57596
89
+ },
90
+ "decoder_start_token_id": 57595,
91
+ "encoder": {
92
+ "_name_or_path": "",
93
+ "add_cross_attention": false,
94
+ "architectures": null,
95
+ "attention_probs_dropout_prob": 0.0,
96
+ "bad_words_ids": null,
97
+ "begin_suppress_tokens": null,
98
+ "bos_token_id": null,
99
+ "chunk_size_feed_forward": 0,
100
+ "cross_attention_hidden_size": null,
101
+ "decoder_start_token_id": null,
102
+ "depths": [
103
+ 2,
104
+ 2,
105
+ 14,
106
+ 2
107
+ ],
108
+ "diversity_penalty": 0.0,
109
+ "do_sample": false,
110
+ "drop_path_rate": 0.1,
111
+ "early_stopping": false,
112
+ "embed_dim": 128,
113
+ "encoder_no_repeat_ngram_size": 0,
114
+ "eos_token_id": null,
115
+ "exponential_decay_length_penalty": null,
116
+ "finetuning_task": null,
117
+ "forced_bos_token_id": null,
118
+ "forced_eos_token_id": null,
119
+ "hidden_act": "gelu",
120
+ "hidden_dropout_prob": 0.0,
121
+ "hidden_size": 1024,
122
+ "id2label": {
123
+ "0": "LABEL_0",
124
+ "1": "LABEL_1"
125
+ },
126
+ "image_size": [
127
+ 1280,
128
+ 960
129
+ ],
130
+ "initializer_range": 0.02,
131
+ "is_decoder": false,
132
+ "is_encoder_decoder": false,
133
+ "label2id": {
134
+ "LABEL_0": 0,
135
+ "LABEL_1": 1
136
+ },
137
+ "layer_norm_eps": 1e-05,
138
+ "length_penalty": 1.0,
139
+ "max_length": 20,
140
+ "min_length": 0,
141
+ "mlp_ratio": 4.0,
142
+ "model_type": "donut-swin",
143
+ "no_repeat_ngram_size": 0,
144
+ "num_beam_groups": 1,
145
+ "num_beams": 1,
146
+ "num_channels": 3,
147
+ "num_heads": [
148
+ 4,
149
+ 8,
150
+ 16,
151
+ 32
152
+ ],
153
+ "num_layers": 4,
154
+ "num_return_sequences": 1,
155
+ "output_attentions": false,
156
+ "output_hidden_states": false,
157
+ "output_scores": false,
158
+ "pad_token_id": null,
159
+ "patch_size": 4,
160
+ "path_norm": true,
161
+ "prefix": null,
162
+ "problem_type": null,
163
+ "pruned_heads": {},
164
+ "qkv_bias": true,
165
+ "remove_invalid_values": false,
166
+ "repetition_penalty": 1.0,
167
+ "return_dict": true,
168
+ "return_dict_in_generate": false,
169
+ "sep_token_id": null,
170
+ "suppress_tokens": null,
171
+ "task_specific_params": null,
172
+ "temperature": 1.0,
173
+ "tf_legacy_loss": false,
174
+ "tie_encoder_decoder": false,
175
+ "tie_word_embeddings": true,
176
+ "tokenizer_class": null,
177
+ "top_k": 50,
178
+ "top_p": 1.0,
179
+ "torch_dtype": null,
180
+ "torchscript": false,
181
+ "typical_p": 1.0,
182
+ "use_absolute_embeddings": false,
183
+ "use_bfloat16": false,
184
+ "window_size": 10
185
+ },
186
+ "is_encoder_decoder": true,
187
+ "model_type": "vision-encoder-decoder",
188
+ "pad_token_id": 1,
189
+ "tie_word_embeddings": false,
190
+ "torch_dtype": "float32",
191
+ "transformers_version": "4.34.0.dev0"
192
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "decoder_start_token_id": 57595,
5
+ "eos_token_id": 2,
6
+ "forced_eos_token_id": 2,
7
+ "max_length": 768,
8
+ "pad_token_id": 1,
9
+ "transformers_version": "4.34.0.dev0"
10
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_align_long_axis": false,
3
+ "do_normalize": true,
4
+ "do_pad": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "do_thumbnail": true,
8
+ "image_mean": [
9
+ 0.5,
10
+ 0.5,
11
+ 0.5
12
+ ],
13
+ "image_processor_type": "DonutImageProcessor",
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "DonutProcessor",
20
+ "resample": 2,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": [
23
+ 960,
24
+ 1280
25
+ ]
26
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebe7d377a60345bd02a7572f4f04053ad5504cc21ef32ef05a5b9fef13ee957f
3
+ size 809469721
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb9e3dce4c326195d08fc3dd0f7e2eee1da8595c847bf4c1a9c78b7a82d47e2d
3
+ size 1296245
special_tokens_map.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<s_iitcdip>",
4
+ "<s_synthdog>"
5
+ ],
6
+ "bos_token": "<s>",
7
+ "cls_token": "<s>",
8
+ "eos_token": "</s>",
9
+ "mask_token": {
10
+ "content": "<mask>",
11
+ "lstrip": true,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<pad>",
17
+ "sep_token": "</s>",
18
+ "unk_token": "<unk>"
19
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "<s>",
5
+ "eos_token": "</s>",
6
+ "mask_token": {
7
+ "__type": "AddedToken",
8
+ "content": "<mask>",
9
+ "lstrip": true,
10
+ "normalized": true,
11
+ "rstrip": false,
12
+ "single_word": false
13
+ },
14
+ "model_max_length": 1000000000000000019884624838656,
15
+ "pad_token": "<pad>",
16
+ "processor_class": "DonutProcessor",
17
+ "sep_token": "</s>",
18
+ "sp_model_kwargs": {},
19
+ "tokenizer_class": "XLMRobertaTokenizer",
20
+ "unk_token": "<unk>"
21
+ }