forked from Calamari-OCR/calamari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
283 lines (233 loc) · 11.2 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Workaround to install python packages again, because sometimes they are not found
before_script:
- set -e
- virtualenv -p python3 venv
- source venv/bin/activate
- pip install -r requirements.txt
- python setup.py install
cache:
paths:
- .cache/pip
- venv
- calamari_models
policy: pull
stages:
- install_dependencies
- test
install_dependencies:
stage: install_dependencies
cache:
paths:
- .cache/pip
- venv
- calamari_models
policy: pull-push
before_script:
- set -e
- rm -rf venv
- rm -rf calamari_models
script:
- set -e
- virtualenv -p python3 venv
- source venv/bin/activate
- pip install -r requirements.txt
- python setup.py install
- wget -q -O - https://github.com/Calamari-OCR/calamari_models/archive/1.0.tar.gz | tar xz && mv calamari_models-1.0 calamari_models
# General training with and without validation or data augmentation
test-cpu:
stage: test
script:
- set -e
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10
test-cpu-validation:
stage: test
script:
- set -e
- calamari-train --validation calamari_ocr/test/data/uw3_50lines/train/*.png --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --early_stopping_frequency 5
test-cpu-augmentation:
stage: test
script:
- set -e
- calamari-train --n_augmentation 5 --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10
test-cpu-validation-augmentation:
stage: test
script:
- set -e
- calamari-train --n_augmentation 5 --validation calamari_ocr/test/data/uw3_50lines/train/*.png --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --early_stopping_frequency 5
# cross-fold-training
test-cpu-cross-fold-train:
stage: test
script:
- set -e
- calamari-cross-fold-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --n_folds 3 --best_models_dir tmp_best_models --max_iters 10
test-cpu-cross-fold-train-augmentation:
stage: test
script:
- set -e
- calamari-cross-fold-train --n_augmentation 5 --files calamari_ocr/test/data/uw3_50lines/train/*.png --n_folds 3 --best_models_dir tmp_best_models --max_iters 10
test-cpu-cross-fold-train-preload:
stage: test
script:
- set -e
- calamari-cross-fold-train --weights calamari_models/antiqua_modern/0.ckpt.json --files calamari_ocr/test/data/uw3_50lines/train/*.png --n_folds 3 --best_models_dir tmp_best_models --max_iters 10
test-cpu-cross-fold-train-preload5:
stage: test
script:
- set -e
- calamari-cross-fold-train --weights calamari_models/antiqua_modern/0.ckpt.json calamari_models/antiqua_modern/1.ckpt.json calamari_models/antiqua_modern/2.ckpt.json calamari_models/antiqua_modern/3.ckpt.json calamari_models/antiqua_modern/4.ckpt.json --files calamari_ocr/test/data/uw3_50lines/train/*.png --n_folds 5 --best_models_dir tmp_best_models --max_iters 10
# prediction and evaluation including voting
test-cpu-predict-and-eval-with-voting:
stage: test
script:
- set -e
- calamari-predict --files calamari_ocr/test/data/uw3_50lines/test/*.png --checkpoint calamari_models/antiqua_modern/0.ckpt.json
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/test/*.gt.txt
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/test/*.gt.txt --skip_empty_gt
- calamari-predict --files calamari_ocr/test/data/uw3_50lines/test/*.png --checkpoint calamari_models/antiqua_modern/*.ckpt.json
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/test/*.gt.txt --n_worst_lines 10 --xlsx_output text.xlsx
# loading pretrained model
test-cpu-pretrained:
stage: test
script:
- set -e
- calamari-train --weights calamari_models/antiqua_historical/0.ckpt.json --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10
test-cpu-pretrained-keep-loaded-codec:
stage: test
script:
- set -e
- calamari-train --weights calamari_models/antiqua_historical/0.ckpt.json --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --keep_loaded_codec
# on-the-fly data loading
test-cpu-data-on-the-fly:
stage: test
script:
- set -e
- calamari-train --train_data_on_the_fly --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10
test-cpu-data-on-the-fly-with-weights:
stage: test
script:
- set -e
- calamari-train --train_data_on_the_fly --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --weights calamari_models/antiqua_modern/0.ckpt.json
test-cpu-validation-data-on-the-fly:
stage: test
script:
- set -e
- calamari-train --train_data_on_the_fly --validation_data_on_the_fly --validation calamari_ocr/test/data/uw3_50lines/train/*.png --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --early_stopping_frequency 5
test-cpu-cross-fold-train-augmentation-data-on-the-fly:
stage: test
script:
- set -e
- calamari-cross-fold-train --train_data_on_the_fly --validation_data_on_the_fly --n_augmentation 5 --files calamari_ocr/test/data/uw3_50lines/train/*.png --n_folds 3 --best_models_dir tmp_best_models --max_iters 10
# extended prediction data and average prediction confidence computation
test-cpu-predict-and-eval-with-voting-extended-prediction-data-avg-conf:
stage: test
script:
- set -e
- calamari-predict --extended_prediction_data --files calamari_ocr/test/data/uw3_50lines/test/*.png --checkpoint calamari_models/antiqua_modern/0.ckpt.json
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/test/*.gt.txt
- python calamari_ocr/scripts/compute_average_prediction_confidence.py --pred calamari_ocr/test/data/uw3_50lines/test/*.json
- calamari-predict --extended_prediction_data --files calamari_ocr/test/data/uw3_50lines/test/*.png --checkpoint calamari_models/antiqua_modern/*.ckpt.json
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/test/*.gt.txt
- python calamari_ocr/scripts/compute_average_prediction_confidence.py --pred calamari_ocr/test/data/uw3_50lines/test/*.json
# train on generated lines
test-cpu-train-on-generated-lines:
stage: test
script:
- set -e
- >
calamari-train
--dataset GENERATED_LINE
--text_generator_params calamari_ocr/test/data/line_generation_config/text_gen_params.json
--line_generator_params calamari_ocr/test/data/line_generation_config/line_gen_params.json
--whitelist_files calamari_ocr/test/data/line_generation_config/whitelist.txt
--no_auto_compute_codec --checkpoint_frequency 5 --display 1.01 --train_data_on_the_fly
--num_threads 4 --batch_size 4 --max_iter 10
# PAGE-XML
test-cpu-train-on-page-xml:
stage: test
script:
- set -e
- >
calamari-train
--files calamari_ocr/test/data/avicanon_pagexml/006.nrm.png calamari_ocr/test/data/avicanon_pagexml/007.nrm.png
--validation calamari_ocr/test/data/avicanon_pagexml/008.nrm.png --validation_dataset PAGEXML
--dataset PAGEXML --display 1.01 --num_threads 1 --early_stopping_frequency 5 --max_iter 10
- >
calamari-cross-fold-train --train_data_on_the_fly --validation_data_on_the_fly --n_augmentation 5
--files calamari_ocr/test/data/avicanon_pagexml/006.nrm.png calamari_ocr/test/data/avicanon_pagexml/007.nrm.png
--dataset PAGEXML --display 1.01
--n_folds 3 --best_models_dir tmp_best_models --max_iters 10
- >
calamari-cross-fold-train --train_data_on_the_fly --validation_data_on_the_fly --n_augmentation 5
--files calamari_ocr/test/data/avicanon_pagexml/006.nrm.png calamari_ocr/test/data/avicanon_pagexml/007.nrm.png
--dataset PAGEXML --display 1.01
--n_folds 3 --best_models_dir tmp_best_models --max_iters 10 --dataset_pad 3 0
test-cpu-train-on-page-xml-validation-on-files:
stage: test
script:
- set -e
- >
calamari-train
--files calamari_ocr/test/data/avicanon_pagexml/006.nrm.png calamari_ocr/test/data/avicanon_pagexml/007.nrm.png
--validation calamari_ocr/test/data/uw3_50lines/test/*.png
--dataset PAGEXML --display 1.01 --num_threads 1 --early_stopping_frequency 5 --max_iter 10
test-cpu-predict-and-eval-page-xml:
stage: test
script:
- set -e
- calamari-predict --files calamari_ocr/test/data/avicanon_pagexml/009.nrm.png --checkpoint calamari_models/antiqua_modern/0.ckpt.json --dataset PAGEXML
- calamari-eval --gt calamari_ocr/test/data/avicanon_pagexml/009.xml --dataset PAGEXML --pred_ext .pred.xml
- calamari-predict --files calamari_ocr/test/data/avicanon_pagexml/009.nrm.png --checkpoint calamari_models/antiqua_modern/0.ckpt.json --dataset PAGEXML --dataset_pad 3 3
# HDF5
test-cpu-train-on-hdf5:
stage: test
script:
- set -e
- >
calamari-train
--files calamari_ocr/test/data/uw3_50lines/uw3-50lines.h5
--validation calamari_ocr/test/data/uw3_50lines/uw3-50lines.h5 --validation_dataset HDF5
--dataset HDF5 --display 1.01 --num_threads 2 --early_stopping_frequency 5 --max_iter 10
--data_preprocessing NOOP_NORMALIZER
test-cpu-predict-and-eval-hdf5:
stage: test
script:
- set -e
- calamari-predict --files calamari_ocr/test/data/uw3_50lines/uw3-50lines.h5 --checkpoint calamari_models/antiqua_modern/0.ckpt.json --dataset HDF5
- calamari-eval --gt calamari_ocr/test/data/uw3_50lines/uw3-50lines.h5 --dataset HDF5 --pred_ext .pred.h5 --n_worst_lines 100
# ABBYY-XML
test-cpu-train-on-abbyy-xml:
stage: test
script:
- set -e
- >
calamari-train
--files calamari_ocr/test/data/hiltl_die_bank_des_verderbens_abbyyxml/*.jpg
--validation calamari_ocr/test/data/hiltl_die_bank_des_verderbens_abbyyxml/*.jpg --validation_dataset ABBYY
--dataset ABBYY --display 1.01 --num_threads 1 --early_stopping_frequency 5 --max_iter 10
test-cpu-train-on-aabbyy-xml-validation-on-page-xml:
stage: test
script:
- set -e
- >
calamari-train
--files calamari_ocr/test/data/hiltl_die_bank_des_verderbens_abbyyxml/*.jpg
--validation calamari_ocr/test/data/avicanon_pagexml/008.nrm.png --validation_dataset PAGEXML
--dataset ABBYY --display 1.01 --num_threads 1 --early_stopping_frequency 5 --max_iter 10
test-cpu-predict-and-eval-abbyy-xml:
stage: test
script:
- set -e
- calamari-predict --files calamari_ocr/test/data/hiltl_die_bank_des_verderbens_abbyyxml/*.jpg --checkpoint calamari_models/antiqua_modern/0.ckpt.json --dataset ABBYY
- calamari-eval --gt calamari_ocr/test/data/hiltl_die_bank_des_verderbens_abbyyxml/*.abbyy.xml --dataset ABBYY --pred_ext .pred.abbyy.xml
# NETWORK ARCHITECTURES
test-cpu-network-architectures:
stage: test
script:
- set -
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --network 'cnn=40:3x3,pool=2x2,lstm=50,dropout=0.5'
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --network 'cnn=40:3x3,pool=2x2'
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --network 'cnn=40:3x3,pool=2x2,db=40:4:3x3'
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --network 'cnn=40:3x3,pool=2x2,db=40:4:3x3,tcnn=40:2x2'
- calamari-train --files calamari_ocr/test/data/uw3_50lines/train/*.png --max_iters 10 --network 'cnn=40:3x3,pool=2x2,db=40:4:3x3,tcnn=40:2x2,concat=1:-1'