albertklorer parquet-converter commited on
Commit
1d87251
·
verified ·
0 Parent(s):

Duplicate from aharley/rvl_cdip

Browse files

Co-authored-by: Parquet-converter (BOT) <parquet-converter@users.noreply.huggingface.co>

Files changed (8) hide show
  1. .gitattributes +39 -0
  2. README.md +229 -0
  3. data/rvl-cdip.tar.gz +3 -0
  4. data/test.txt +3 -0
  5. data/train.txt +3 -0
  6. data/val.txt +3 -0
  7. dataset_infos.json +1 -0
  8. rvl_cdip.py +146 -0
.gitattributes ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.wasm filter=lfs diff=lfs merge=lfs -text
25
+ *.xz filter=lfs diff=lfs merge=lfs -text
26
+ *.zip filter=lfs diff=lfs merge=lfs -text
27
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
28
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
29
+ # Audio files - uncompressed
30
+ *.pcm filter=lfs diff=lfs merge=lfs -text
31
+ *.sam filter=lfs diff=lfs merge=lfs -text
32
+ *.raw filter=lfs diff=lfs merge=lfs -text
33
+ # Audio files - compressed
34
+ *.aac filter=lfs diff=lfs merge=lfs -text
35
+ *.flac filter=lfs diff=lfs merge=lfs -text
36
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
37
+ *.ogg filter=lfs diff=lfs merge=lfs -text
38
+ *.wav filter=lfs diff=lfs merge=lfs -text
39
+ *.txt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language_creators:
5
+ - found
6
+ language:
7
+ - en
8
+ license:
9
+ - other
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - 100K<n<1M
14
+ source_datasets:
15
+ - extended|iit_cdip
16
+ task_categories:
17
+ - image-classification
18
+ task_ids:
19
+ - multi-class-image-classification
20
+ paperswithcode_id: rvl-cdip
21
+ pretty_name: RVL-CDIP
22
+ viewer: false
23
+ dataset_info:
24
+ features:
25
+ - name: image
26
+ dtype: image
27
+ - name: label
28
+ dtype:
29
+ class_label:
30
+ names:
31
+ '0': letter
32
+ '1': form
33
+ '2': email
34
+ '3': handwritten
35
+ '4': advertisement
36
+ '5': scientific report
37
+ '6': scientific publication
38
+ '7': specification
39
+ '8': file folder
40
+ '9': news article
41
+ '10': budget
42
+ '11': invoice
43
+ '12': presentation
44
+ '13': questionnaire
45
+ '14': resume
46
+ '15': memo
47
+ splits:
48
+ - name: train
49
+ num_bytes: 38816373360
50
+ num_examples: 320000
51
+ - name: test
52
+ num_bytes: 4863300853
53
+ num_examples: 40000
54
+ - name: validation
55
+ num_bytes: 4868685208
56
+ num_examples: 40000
57
+ download_size: 38779484559
58
+ dataset_size: 48548359421
59
+ ---
60
+
61
+ # Dataset Card for RVL-CDIP
62
+
63
+ ## Table of Contents
64
+ - [Dataset Description](#dataset-description)
65
+ - [Dataset Summary](#dataset-summary)
66
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
67
+ - [Languages](#languages)
68
+ - [Dataset Structure](#dataset-structure)
69
+ - [Data Instances](#data-instances)
70
+ - [Data Fields](#data-instances)
71
+ - [Data Splits](#data-instances)
72
+ - [Dataset Creation](#dataset-creation)
73
+ - [Curation Rationale](#curation-rationale)
74
+ - [Source Data](#source-data)
75
+ - [Annotations](#annotations)
76
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
77
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
78
+ - [Social Impact of Dataset](#social-impact-of-dataset)
79
+ - [Discussion of Biases](#discussion-of-biases)
80
+ - [Other Known Limitations](#other-known-limitations)
81
+ - [Additional Information](#additional-information)
82
+ - [Dataset Curators](#dataset-curators)
83
+ - [Licensing Information](#licensing-information)
84
+ - [Citation Information](#citation-information)
85
+
86
+ ## Dataset Description
87
+
88
+ - **Homepage:** [The RVL-CDIP Dataset](https://www.cs.cmu.edu/~aharley/rvl-cdip/)
89
+ - **Repository:**
90
+ - **Paper:** [Evaluation of Deep Convolutional Nets for Document Image Classification and Retrieval](https://arxiv.org/abs/1502.07058)
91
+ - **Leaderboard:** [RVL-CDIP leaderboard](https://paperswithcode.com/dataset/rvl-cdip)
92
+ - **Point of Contact:** [Adam W. Harley](mailto:aharley@cmu.edu)
93
+
94
+ ### Dataset Summary
95
+
96
+ The RVL-CDIP (Ryerson Vision Lab Complex Document Information Processing) dataset consists of 400,000 grayscale images in 16 classes, with 25,000 images per class. There are 320,000 training images, 40,000 validation images, and 40,000 test images. The images are sized so their largest dimension does not exceed 1000 pixels.
97
+
98
+ ### Supported Tasks and Leaderboards
99
+
100
+ - `image-classification`: The goal of this task is to classify a given document into one of 16 classes representing document types (letter, form, etc.). The leaderboard for this task is available [here](https://paperswithcode.com/sota/document-image-classification-on-rvl-cdip).
101
+
102
+ ### Languages
103
+
104
+ All the classes and documents use English as their primary language.
105
+
106
+ ## Dataset Structure
107
+
108
+ ### Data Instances
109
+
110
+ A sample from the training set is provided below :
111
+ ```
112
+ {
113
+ 'image': <PIL.TiffImagePlugin.TiffImageFile image mode=L size=754x1000 at 0x7F9A5E92CA90>,
114
+ 'label': 15
115
+ }
116
+ ```
117
+
118
+ ### Data Fields
119
+
120
+ - `image`: A `PIL.Image.Image` object containing a document.
121
+ - `label`: an `int` classification label.
122
+
123
+ <details>
124
+ <summary>Class Label Mappings</summary>
125
+
126
+ ```json
127
+ {
128
+ "0": "letter",
129
+ "1": "form",
130
+ "2": "email",
131
+ "3": "handwritten",
132
+ "4": "advertisement",
133
+ "5": "scientific report",
134
+ "6": "scientific publication",
135
+ "7": "specification",
136
+ "8": "file folder",
137
+ "9": "news article",
138
+ "10": "budget",
139
+ "11": "invoice",
140
+ "12": "presentation",
141
+ "13": "questionnaire",
142
+ "14": "resume",
143
+ "15": "memo"
144
+ }
145
+ ```
146
+
147
+ </details>
148
+
149
+ ### Data Splits
150
+
151
+ | |train|test|validation|
152
+ |----------|----:|----:|---------:|
153
+ |# of examples|320000|40000|40000|
154
+
155
+ The dataset was split in proportions similar to those of ImageNet.
156
+ - 320000 images were used for training,
157
+ - 40000 images for validation, and
158
+ - 40000 images for testing.
159
+
160
+ ## Dataset Creation
161
+
162
+ ### Curation Rationale
163
+
164
+ From the paper:
165
+ > This work makes available a new labelled subset of the IIT-CDIP collection, containing 400,000
166
+ document images across 16 categories, useful for training new CNNs for document analysis.
167
+
168
+ ### Source Data
169
+
170
+ #### Initial Data Collection and Normalization
171
+
172
+ The same as in the IIT-CDIP collection.
173
+
174
+ #### Who are the source language producers?
175
+
176
+ The same as in the IIT-CDIP collection.
177
+
178
+ ### Annotations
179
+
180
+ #### Annotation process
181
+
182
+ The same as in the IIT-CDIP collection.
183
+
184
+ #### Who are the annotators?
185
+
186
+ The same as in the IIT-CDIP collection.
187
+
188
+ ### Personal and Sensitive Information
189
+
190
+ [More Information Needed]
191
+
192
+ ## Considerations for Using the Data
193
+
194
+ ### Social Impact of Dataset
195
+
196
+ [More Information Needed]
197
+
198
+ ### Discussion of Biases
199
+
200
+ [More Information Needed]
201
+
202
+ ### Other Known Limitations
203
+
204
+ [More Information Needed]
205
+
206
+ ## Additional Information
207
+
208
+ ### Dataset Curators
209
+
210
+ The dataset was curated by the authors - Adam W. Harley, Alex Ufkes, and Konstantinos G. Derpanis.
211
+
212
+ ### Licensing Information
213
+
214
+ RVL-CDIP is a subset of IIT-CDIP, which came from the [Legacy Tobacco Document Library](https://www.industrydocuments.ucsf.edu/tobacco/), for which license information can be found [here](https://www.industrydocuments.ucsf.edu/help/copyright/).
215
+
216
+ ### Citation Information
217
+
218
+ ```bibtex
219
+ @inproceedings{harley2015icdar,
220
+ title = {Evaluation of Deep Convolutional Nets for Document Image Classification and Retrieval},
221
+ author = {Adam W Harley and Alex Ufkes and Konstantinos G Derpanis},
222
+ booktitle = {International Conference on Document Analysis and Recognition ({ICDAR})}},
223
+ year = {2015}
224
+ }
225
+ ```
226
+
227
+ ### Contributions
228
+
229
+ Thanks to [@dnaveenr](https://github.com/dnaveenr) for adding this dataset.
data/rvl-cdip.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3577e655813922098cd776422479017be37612ec17a65076b1b62199bf8b28a2
3
+ size 38762320458
data/test.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97699c1c56425c4482632742381289b7bf855c23cd020253d7cb29df638ba1a3
3
+ size 1717144
data/train.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d25bf09a99d8691883dfebbc783046fb963437ce90b313ad0b81cab451fc17b
3
+ size 13730846
data/val.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:748483211bda619ab5fc3d395bd7dbfb6cac025753a13fc6abe500280e4e963a
3
+ size 1716111
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default": {"description": "The RVL-CDIP (Ryerson Vision Lab Complex Document Information Processing) dataset consists of 400,000 grayscale images in 16 classes, with 25,000 images per class. There are 320,000 training images, 40,000 validation images, and 40,000 test images.\n", "citation": "@inproceedings{harley2015icdar,\n title = {Evaluation of Deep Convolutional Nets for Document Image Classification and Retrieval},\n author = {Adam W Harley and Alex Ufkes and Konstantinos G Derpanis},\n booktitle = {International Conference on Document Analysis and Recognition ({ICDAR})}},\n year = {2015}\n}\n", "homepage": "https://www.cs.cmu.edu/~aharley/rvl-cdip/", "license": "https://www.industrydocuments.ucsf.edu/help/copyright/", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "label": {"num_classes": 16, "names": ["letter", "form", "email", "handwritten", "advertisement", "scientific report", "scientific publication", "specification", "file folder", "news article", "budget", "invoice", "presentation", "questionnaire", "resume", "memo"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": {"input": "image", "output": "label"}, "task_templates": [{"task": "image-classification", "image_column": "image", "label_column": "label"}], "builder_name": "rvl_cdip", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 38816373360, "num_examples": 320000, "dataset_name": "rvl_cdip"}, "test": {"name": "test", "num_bytes": 4863300853, "num_examples": 40000, "dataset_name": "rvl_cdip"}, "validation": {"name": "validation", "num_bytes": 4868685208, "num_examples": 40000, "dataset_name": "rvl_cdip"}}, "download_checksums": {"https://huggingface.co/datasets/rvl_cdip/resolve/main/data/rvl-cdip.tar.gz": {"num_bytes": 38762320458, "checksum": "3577e655813922098cd776422479017be37612ec17a65076b1b62199bf8b28a2"}, "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/train.txt": {"num_bytes": 13730846, "checksum": "8d25bf09a99d8691883dfebbc783046fb963437ce90b313ad0b81cab451fc17b"}, "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/test.txt": {"num_bytes": 1717144, "checksum": "97699c1c56425c4482632742381289b7bf855c23cd020253d7cb29df638ba1a3"}, "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/val.txt": {"num_bytes": 1716111, "checksum": "748483211bda619ab5fc3d395bd7dbfb6cac025753a13fc6abe500280e4e963a"}}, "download_size": 38779484559, "post_processing_size": null, "dataset_size": 48548359421, "size_in_bytes": 87327843980}}
rvl_cdip.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """RVL-CDIP (Ryerson Vision Lab Complex Document Information Processing) dataset"""
16
+
17
+
18
+ import os
19
+
20
+ import datasets
21
+
22
+
23
+ _CITATION = """\
24
+ @inproceedings{harley2015icdar,
25
+ title = {Evaluation of Deep Convolutional Nets for Document Image Classification and Retrieval},
26
+ author = {Adam W Harley and Alex Ufkes and Konstantinos G Derpanis},
27
+ booktitle = {International Conference on Document Analysis and Recognition ({ICDAR})}},
28
+ year = {2015}
29
+ }
30
+ """
31
+
32
+
33
+ _DESCRIPTION = """\
34
+ The RVL-CDIP (Ryerson Vision Lab Complex Document Information Processing) dataset consists of 400,000 grayscale images in 16 classes, with 25,000 images per class. There are 320,000 training images, 40,000 validation images, and 40,000 test images.
35
+ """
36
+
37
+
38
+ _HOMEPAGE = "https://www.cs.cmu.edu/~aharley/rvl-cdip/"
39
+
40
+
41
+ _LICENSE = "https://www.industrydocuments.ucsf.edu/help/copyright/"
42
+
43
+
44
+ _URLS = {
45
+ "rvl-cdip": "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/rvl-cdip.tar.gz",
46
+ }
47
+
48
+ _METADATA_URLS = {
49
+ "train": "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/train.txt",
50
+ "test": "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/test.txt",
51
+ "val": "https://huggingface.co/datasets/rvl_cdip/resolve/main/data/val.txt",
52
+ }
53
+
54
+ _CLASSES = [
55
+ "letter",
56
+ "form",
57
+ "email",
58
+ "handwritten",
59
+ "advertisement",
60
+ "scientific report",
61
+ "scientific publication",
62
+ "specification",
63
+ "file folder",
64
+ "news article",
65
+ "budget",
66
+ "invoice",
67
+ "presentation",
68
+ "questionnaire",
69
+ "resume",
70
+ "memo",
71
+ ]
72
+
73
+ _IMAGES_DIR = "images/"
74
+
75
+
76
+ class RvlCdip(datasets.GeneratorBasedBuilder):
77
+ """Ryerson Vision Lab Complex Document Information Processing dataset."""
78
+
79
+ VERSION = datasets.Version("1.0.0")
80
+
81
+ def _info(self):
82
+ return datasets.DatasetInfo(
83
+ description=_DESCRIPTION,
84
+ features=datasets.Features(
85
+ {
86
+ "image": datasets.Image(),
87
+ "label": datasets.ClassLabel(names=_CLASSES),
88
+ }
89
+ ),
90
+ supervised_keys=("image", "label"),
91
+ homepage=_HOMEPAGE,
92
+ citation=_CITATION,
93
+ license=_LICENSE,
94
+ )
95
+
96
+ def _split_generators(self, dl_manager):
97
+ archive_path = dl_manager.download(_URLS["rvl-cdip"])
98
+ labels_path = dl_manager.download(_METADATA_URLS)
99
+
100
+ return [
101
+ datasets.SplitGenerator(
102
+ name=datasets.Split.TRAIN,
103
+ gen_kwargs={
104
+ "archive_iterator": dl_manager.iter_archive(archive_path),
105
+ "labels_filepath": labels_path["train"],
106
+ },
107
+ ),
108
+ datasets.SplitGenerator(
109
+ name=datasets.Split.TEST,
110
+ gen_kwargs={
111
+ "archive_iterator": dl_manager.iter_archive(archive_path),
112
+ "labels_filepath": labels_path["test"],
113
+ },
114
+ ),
115
+ datasets.SplitGenerator(
116
+ name=datasets.Split.VALIDATION,
117
+ gen_kwargs={
118
+ "archive_iterator": dl_manager.iter_archive(archive_path),
119
+ "labels_filepath": labels_path["val"],
120
+ },
121
+ ),
122
+ ]
123
+
124
+ @staticmethod
125
+ def _get_image_to_class_map(data):
126
+ image_to_class_id = {}
127
+ for item in data:
128
+ image_path, class_id = item.split(" ")
129
+ image_path = os.path.join(_IMAGES_DIR, image_path)
130
+ image_to_class_id[image_path] = int(class_id)
131
+
132
+ return image_to_class_id
133
+
134
+ def _generate_examples(self, archive_iterator, labels_filepath):
135
+
136
+ with open(labels_filepath, encoding="utf-8") as f:
137
+ data = f.read().splitlines()
138
+
139
+ image_to_class_id = self._get_image_to_class_map(data)
140
+
141
+ for file_path, file_obj in archive_iterator:
142
+ if file_path.startswith(_IMAGES_DIR):
143
+ if file_path in image_to_class_id:
144
+ class_id = image_to_class_id[file_path]
145
+ label = _CLASSES[class_id]
146
+ yield file_path, {"image": {"path": file_path, "bytes": file_obj.read()}, "label": label}