SBB
/

TF-Keras
cneud Jrglmn commited on
Commit
55d91cd
1 Parent(s): 826a992

Added generic model card (#1)

Browse files

- Added generic model card (2064133fa374ebd5e145866bfc1b82aa7b1a7dba)


Co-authored-by: Jörg Lehmann <Jrglmn@users.noreply.huggingface.co>

Files changed (1) hide show
  1. README.md +243 -0
README.md CHANGED
@@ -1,3 +1,246 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ # Model Card for eynollah-textline
6
+
7
+ <!-- Provide a quick summary of what the model is/does. [Optional] -->
8
+ This model is part of a suite of 13 models. The suite introduces an end-to-end pipeline to extract layout, text lines and reading order for historic documents, where the output can be used as an input for OCR engines.
9
+
10
+ Questions and comments about the models can be directed to Vahid Rezanezhad at Vahid.Rezanezhad@sbb.spk-berlin.de.
11
+
12
+ # Table of Contents
13
+
14
+ - [Model Card for eynollah-textline](#model-card-for-eynollah-textline)
15
+ - [Table of Contents](#table-of-contents)
16
+ - [Model Details](#model-details)
17
+ - [Model Description](#model-description)
18
+ - [Uses](#uses)
19
+ - [Direct Use](#direct-use)
20
+ - [Downstream Use](#downstream-use)
21
+ - [Out-of-Scope Use](#out-of-scope-use)
22
+ - [Bias, Risks, and Limitations](#bias-risks-and-limitations)
23
+ - [Recommendations](#recommendations)
24
+ - [Training Details](#training-details)
25
+ - [Training Data](#training-data)
26
+ - [Training Procedure](#training-procedure)
27
+ - [Preprocessing](#preprocessing)
28
+ - [Speeds, Sizes, Times](#speeds-sizes-times)
29
+ - [Evaluation](#evaluation)
30
+ - [Testing Data, Factors and Metrics](#testing-data-factors-and-metrics)
31
+ - [Testing Data](#testing-data)
32
+ - [Metrics](#metrics)
33
+ - [Model Examination](#model-examination)
34
+ - [Environmental Impact](#environmental-impact)
35
+ - [Technical Specifications](#technical-specifications)
36
+ - [Model Architecture and Objective](#model-architecture-and-objective)
37
+ - [Software](#software)
38
+ - [Citation](#citation)
39
+ - [More Information](#more-information)
40
+ - [Model Card Authors](#model-card-authors)
41
+ - [Model Card Contact](#model-card-contact)
42
+ - [How to Get Started with the Model](#how-to-get-started-with-the-model)
43
+
44
+
45
+ # Model Details
46
+
47
+ ## Model Description
48
+
49
+ <!-- Provide a longer summary of what this model is/does. -->
50
+
51
+ This suite of 13 models presents a document layout analysis (DLA) system for historical documents implemented by pixel-wise segmentation using convolutional neural networks. In addition, heuristic methods are applied to detect marginals and to determine the reading order of text regions.
52
+
53
+ The detection and classification of multiple classes of layout elements such as headings, images, tables etc. as part of DLA is required in order to extract and process them in subsequent steps. Altogether, the combination of image detection, classification and segmentation on the wide variety that can be found in over 400 years of printed cultural heritage makes this a very challenging task. Deep learning models are complemented with heuristics for the detection of text lines, marginals, and reading order. Furthermore, an optional image enhancement step was added in case of documents that either have insufficient pixel density and/or require scaling. Also, a column classifier for the analysis of multi-column documents was added. With these additions, DLA performance was improved, and a high accuracy in the prediction of the reading order is accomplished.
54
+
55
+ Two Arabic/Persian terms form the name of the model suite: عين الله, which can be transcribed as "ain'allah" or "eynollah"; it translates into English as "God's Eye" -- it sees (nearly) everything on the document image.
56
+
57
+
58
+
59
+ - **Developed by:** [Vahid Rezanezhad](Vahid.Rezanezhad@sbb.spk-berlin.de)
60
+ - **Shared by:** [Staatsbibliothek zu Berlin / Berlin State Library](https://huggingface.co/SBB)
61
+ - **Model type:** Neural Network
62
+ - **Language(s) (NLP):** Irrelevant; works on all languages
63
+ - **License:** apache-2.0
64
+ - **Resources for more information:**
65
+ - The GitHub Repo can be found [here](https://github.com/qurator-spk/eynollah)
66
+ - Associated Paper: [Document Layout Analysis with Deep Learning and Heuristics](https://doi.org/10.1145/3604951.3605513)
67
+
68
+ # Uses
69
+
70
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
71
+
72
+ The intended use of the suite is performing document layout analysis (DLA) on image data. The system returns the results in [PAGE-XML format](https://github.com/PRImA-Research-Lab/PAGE-XML).
73
+
74
+ ## Direct Use
75
+
76
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
77
+ <!-- If the user enters content, print that. If not, but they enter a task in the list, use that. If neither, say "more info needed." -->
78
+
79
+ The system performs document layout analysis in a series of steps. First, the image is cropped and the number of columns determined. Then the pixels-per-inch (ppi) rate is detected, and when ppi is below 300, the image is re-scaled and enhanced. Now the main region types (text regions, images, separators, background) are detected as the early layout. Marginals are detected with a heuristic method, then -- optionally -- headers (or headings or floatings) and drop capitals. Next, textline segmentation is performed for text regions, and for each text region the slope of deskewing is calculated. Heuristics are used to determine bounding boxes (or contours in the case of curved lines) of textlines in each region after deskewing. After that, the reading order of text regions is detected based on separators, headers (or headings or floatings) and the coordinates of columns. Finally, all results are written to a PAGE-XML file.
80
+
81
+ **Within the suite, the model *eynollah-textline/2021-04-25/saved_model.pb* is used for the task of textline detection**.
82
+
83
+ The method for textline detection combines deep learning and heuristics. In the deep learning part, an image-to-image model performs binary segmentation of the document into the classes textline vs. background. In the heuristics part, bounding boxes or contours are derived from binary segmentation.
84
+
85
+ Skewed documents can heavily affect textline detection accuracy, so robust deskewing is needed. But detecting text lines with rectangle bounding boxes cannot deal with partially curved text lines. To address this, a functionality specifically for documents with curved text lines was included. After finding the contour of a text region and its corresponding textline segmentation, the text region is cut into smaller vertical straps. For each strap, its textline segmentation is first deskewed and then the text lines are separated with the same heuristic method as for finding textline bounding boxes. Later, the strap is rotated back into its original orientation.
86
+
87
+ ## Downstream Use
88
+
89
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
90
+ <!-- If the user enters content, print that. If not, but they enter a task in the list, use that. If neither, say "more info needed." -->
91
+
92
+ The intended use of this suite of 13 models is conceived of as a system. Comparable systems are [dhSegment](https://doi.org/10.1109/ICFHR-2018.2018.00011) and [P2PaLA](https://github.com/lquirosd/P2PaLA). However -- and as always with a system -- , every component can potentially used on its own. Each model might therefore be used or trained for other downstream purposes.
93
+
94
+
95
+ ## Out-of-Scope Use
96
+
97
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
98
+ <!-- If the user enters content, print that. If not, but they enter a task in the list, use that. If neither, say "more info needed." -->
99
+
100
+ This model suite does **NOT** perform any Optical Character Recognition (OCR), it is an image-to-PAGE-XML system only.
101
+
102
+ # Bias, Risks, and Limitations
103
+
104
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
105
+
106
+ The pre-processing of digitised historical and contemporary texts is a task contributing to knowledge creation, both by developing models facilitating the necessary pre-processing steps of document layout analysis and ultimately by enabling better discoverability of information in the processed works. Since the content of the document images is not touched, ethical challenges cannot be identified. The endeavor of developing the model was not undertaken for profit. Though a commercial product based on this model may be developed in the future, it will always remain openly accessible without any commercial interest. The aim of the development of this model was to improve document layout analysis, an endeavour that is not for profit. As a technical limitation, it has to be noted that there is a lot of performance to gain for historical text by adding more historical Ground Truth data.
107
+
108
+ ## Recommendations
109
+
110
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
111
+
112
+ The application of machine learning models to convert a document image into PAGE-XML is a process which can still be improved. The suite of 13 models performs pixel-wise segmentation, which is done in patches; it therefore lacks a global understanding of documents and makes the document layout analysis system unable to detect some document subcategories like page numbers. The end-to-end system with different stages uses the output of each task for the next step. Therefore a poor prediction in early steps may cause a poor final document information extraction. Patch-wise segmentation can cause problems to segment pixels between text blocks, large scale drop capitals, headers and tables, since in each patch the model sees only a part of the document element and not all of it. Therefore, there is a lot to gain by improving the existing model suite.
113
+
114
+ # Training Details
115
+
116
+ ## Training Data
117
+
118
+ <!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
119
+
120
+ For model training, Ground Truth in PAGE-XML format was sourced mainly from three datasets. The [IMPACT dataset of historical document images](https://doi.org/10.1145/2501115.2501130) contains a representative sample of historical books and newspapers from Europe’s major libraries. Due to restrictions, only the open data from the National Library of the Netherlands (KB) and the Poznan Supercomputing and Networking Center (PSNC) were used. The [Europeana Newspapers Project (ENP) image and ground truth dataset of historical newspapers](https://doi.org/10.1109/ICDAR.2015.7333898) contains images representative of the newspaper digitisation projects of 12 national and major European libraries. The [OCR-D dataset](https://doi.org/10.1145/3322905.3322916) of German prints between 1500 and 1900 is based on a selection from the holdings of the “German Text Archive” (DTA), the Digitized Collections of the Berlin State Library and the Wolfenbüttel Digital Library.
121
+
122
+ ## Training Procedure
123
+
124
+ All models, except for the column classifier, are designed for pixelwise segmentation. The training of these models follows a patchwise approach, wherein the documents are divided into smaller patches and fed into the models during training. To train these segmentation models, annotated labels are required. Each sub-element in the document is assigned a unique value for identification.
125
+
126
+ If you consider examining the training process, take a look at the repository which contains the source code for training an encoder model for document image segmentation [on GitHub](https://github.com/qurator-spk/sbb_pixelwise_segmentation).
127
+
128
+
129
+ ### Preprocessing
130
+
131
+ In order to use this suite of models for historical documents, no preprocessing is needed for the input images.
132
+
133
+ ### Speeds, Sizes, Times
134
+
135
+ The duration of training per epoch varies, typically lasting between 2 to 5 hours, depending on the specific use case, the datasets used, and the extent of applied data augmentation.
136
+ Our ResNet-50-U-Net model has 38.15M parameters where only parameters of the decoder part are fully trained (14.71M parameters).
137
+ In the case of the column classifier, we used a ResNet-50 with two dense connected layers at the top. The column classifier model has 25.6M parameters, where only parameters of dense layers are fully trained (2.16M parameters).
138
+
139
+ ### Training hyperparameters
140
+
141
+ Within the context of a constant model architecture, our hyperparameters encompass diverse augmentations, each characterized by its unique set of parameters. In addition to these, the model training process involves other hyperparameters, including the choice of the loss function, the number of batches utilized, the patch size of input images, and the number of epochs.
142
+
143
+ ### Training results
144
+
145
+ Training results are reported in [this paper](https://doi.org/10.1145/3604951.3605513).
146
+
147
+ # Evaluation
148
+
149
+ Given the inadequacy of the prevailing segmentation metric in achieving optimal outcomes for document segmentation, particularly with respect to isolating regions as effectively as desired, we proceeded to evaluate our model using smaller batches of the three above-named datasets used for training. In pursuit of improved results, we employed an ensemble learning approach by aggregating the best epoch weights.
150
+
151
+ ## Testing Data, Factors and Metrics
152
+
153
+ ### Testing Data
154
+
155
+ Three new datasets were used for evaluation to ensure an unbiased comparison. [The PRImA Layout Analysis Dataset](https://www.primaresearch.org/datasets/Layout_Analysis) contains 478 pages of realistic documents, reflecting various challenges in layout analysis.
156
+ [The German-Brazilian Newspapers (GBN) Dataset](https://web.inf.ufpr.br/vri/databases/gbn/) comprises 152 pages from historical newspapers. We used only 61 pages to keep the complexity of the documents similar. Finally, the (unreleased) Vlaamse Erfgoedbibliotheken (VEB) dataset comprises ground truth for 75 pages from historical Belgian newspapers, split across three sets.
157
+
158
+ ### Metrics
159
+
160
+ In addition to utilizing conventional performance metrics such as mean Intersection over Union (mIoU), precision, recall, and F1-score, we have incorporated the [Prima layout evaluation](https://www.primaresearch.org/tools/PerformanceEvaluation) metrics, namely Merge, Split, Miss, and the overall success rate.
161
+
162
+ # Model Examination
163
+
164
+ Examination results are reported in [this paper](https://doi.org/10.1145/3604951.3605513).
165
+
166
+ # Environmental Impact
167
+
168
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
169
+
170
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
171
+
172
+ - **Hardware Type:** GeForce RTX 2070
173
+ - **Hours used:** 2 to 5 hours per epoch
174
+ - **Cloud Provider:** No cloud.
175
+ - **Compute Region:** Germany.
176
+ - **Carbon Emitted:** More information needed.
177
+
178
+ # Technical Specifications
179
+
180
+ ## Model Architecture and Objective
181
+
182
+ See [publication](https://doi.org/10.1145/3604951.3605513).
183
+
184
+ ### Software
185
+
186
+ See the code published on [GitHub](https://github.com/qurator-spk/eynollah).
187
+
188
+ # Citation
189
+
190
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
191
+
192
+
193
+
194
+ **BibTeX:**
195
+
196
+ ```bibtex
197
+ @inproceedings{10.1145/3604951.3605513,
198
+ author = {Rezanezhad, Vahid and Baierer, Konstantin and Gerber, Mike and Labusch, Kai and Neudecker, Clemens},
199
+ title = {Document Layout Analysis with Deep Learning and Heuristics},
200
+ year = {2023},
201
+ isbn = {9798400708411},
202
+ publisher = {Association for Computing Machinery},
203
+ address = {New York, NY, USA},
204
+ url = {https://doi.org/10.1145/3604951.3605513},
205
+ doi = {10.1145/3604951.3605513},
206
+ abstract = {The automated yet highly accurate layout analysis (segmentation) of historical document images remains a key challenge for the improvement of Optical Character Recognition (OCR) results. But historical documents exhibit a wide array of features that disturb layout analysis, such as multiple columns, drop capitals and illustrations, skewed or curved text lines, noise, annotations, etc. We present a document layout analysis (DLA) system for historical documents implemented by pixel-wise segmentation using convolutional neural networks. In addition, heuristic methods are applied to detect marginals and to determine the reading order of text regions. Our system can detect more layout classes (e.g. initials, marginals) and achieves higher accuracy than competitive approaches. We describe the algorithm, the different models and how they were trained and discuss our results in comparison to the state-of-the-art on the basis of three historical document datasets.},
207
+ booktitle = {Proceedings of the 7th International Workshop on Historical Document Imaging and Processing},
208
+ pages = {73–78},
209
+ numpages = {6},
210
+ keywords = {Document layout analysis, Reading order detection, Segmentation},
211
+ location = {San Jose, CA, USA},
212
+ series = {HIP '23}
213
+ }
214
+ ```
215
+
216
+ **APA:**
217
+
218
+ (Rezanezhad et al., 2023)
219
+
220
+ # More Information
221
+
222
+ SHA256 and MD5 hashes for the model *eynollah-textline/2021-04-25/saved_model.pb*:
223
+
224
+ SHA256: 80a97f4478ccab442d4a9e23d3338698f362453d7f94ba8bc05f44a738c10844
225
+ MD5: 52bb236b1126c2be3587cdd7feacf1a3
226
+
227
+
228
+ # Model Card Authors
229
+
230
+ <!-- This section provides another layer of transparency and accountability. Whose views is this model card representing? How many voices were included in its construction? Etc. -->
231
+
232
+ [Vahid Rezanezhad](vahid.rezanezhad@sbb.spk-berlin.de), [Clemens Neudecker](clemens.neudecker@sbb.spk-berlin.de) and [Jörg Lehmann](joerg.lehmann@sbb.spk-berlin.de)
233
+
234
+ # Model Card Contact
235
+
236
+ Questions and comments about the model can be directed to [Vahid Rezanezhad](Vahid.Rezanezhad@sbb.spk-berlin.de), questions and comments about the model card can be directed to [Jörg Lehmann](joerg.lehmann@sbb.spk-berlin.de).
237
+
238
+ # How to Get Started with the Model
239
+
240
+ How to get started with this model is explained in the ReadMe file of the GitHub repository [over here](https://github.com/qurator-spk/eynollah).
241
+
242
+ &nbsp;
243
+
244
+ Model Card as of August 17th, 2023
245
+
246
+