Convert to parquet (loading scripts are no longer supported)

#5
by davanstrien HF Staff - opened
README.md CHANGED
@@ -18,6 +18,57 @@ task_categories:
18
  - image-classification
19
  task_ids:
20
  - multi-class-image-classification
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ---
22
 
23
 
 
18
  - image-classification
19
  task_ids:
20
  - multi-class-image-classification
21
+ dataset_info:
22
+ features:
23
+ - name: file
24
+ dtype: string
25
+ - name: label
26
+ dtype:
27
+ class_label:
28
+ names:
29
+ '0': text-only
30
+ '1': illustrations
31
+ - name: pub_date
32
+ dtype: timestamp[ns]
33
+ - name: page_seq_num
34
+ dtype: int64
35
+ - name: edition_seq_num
36
+ dtype: int64
37
+ - name: batch
38
+ dtype: string
39
+ - name: lccn
40
+ dtype: string
41
+ - name: box
42
+ list: float32
43
+ - name: score
44
+ dtype: float64
45
+ - name: ocr
46
+ dtype: string
47
+ - name: place_of_publication
48
+ dtype: string
49
+ - name: geographic_coverage
50
+ dtype: string
51
+ - name: name
52
+ dtype: string
53
+ - name: publisher
54
+ dtype: string
55
+ - name: url
56
+ dtype: string
57
+ - name: page_url
58
+ dtype: string
59
+ - name: image
60
+ dtype: image
61
+ splits:
62
+ - name: train
63
+ num_bytes: 48233897
64
+ num_examples: 549
65
+ download_size: 48045363
66
+ dataset_size: 48233897
67
+ configs:
68
+ - config_name: default
69
+ data_files:
70
+ - split: train
71
+ path: data/train-*
72
  ---
73
 
74
 
data/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e3278cf7eb2744ab80ad1576df7853a12217a8289b47812f395f3c56330bcdf
3
+ size 48045363
dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"default": {"description": "The Dataset contains images derived from the Newspaper Navigator (news-navigator.labs.loc.gov/), a dataset of images drawn from the Library of Congress Chronicling America collection. \n", "citation": "@dataset{van_strien_daniel_2021_5838410,\n author = {van Strien, Daniel},\n title = {{19th Century United States Newspaper Advert images \n with 'illustrated' or 'non illustrated' labels}},\n month = oct,\n year = 2021,\n publisher = {Zenodo},\n version = {0.0.1},\n doi = {10.5281/zenodo.5838410},\n url = {https://doi.org/10.5281/zenodo.5838410}}\n", "homepage": "https://doi.org/10.5281/zenodo.5838410", "license": "Public Domain", "features": {"file": {"dtype": "string", "id": null, "_type": "Value"}, "image": {"decode": true, "id": null, "_type": "Image"}, "label": {"num_classes": 2, "names": ["text-only", "illustrations"], "id": null, "_type": "ClassLabel"}, "pub_date": {"dtype": "timestamp[ns]", "id": null, "_type": "Value"}, "page_seq_num": {"dtype": "int64", "id": null, "_type": "Value"}, "edition_seq_num": {"dtype": "int64", "id": null, "_type": "Value"}, "batch": {"dtype": "string", "id": null, "_type": "Value"}, "lccn": {"dtype": "string", "id": null, "_type": "Value"}, "box": {"feature": {"dtype": "float32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "score": {"dtype": "float64", "id": null, "_type": "Value"}, "ocr": {"dtype": "string", "id": null, "_type": "Value"}, "place_of_publication": {"dtype": "string", "id": null, "_type": "Value"}, "geographic_coverage": {"dtype": "string", "id": null, "_type": "Value"}, "name": {"dtype": "string", "id": null, "_type": "Value"}, "publisher": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "page_url": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "illustrated_ads", "config_name": "default", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 773969, "num_examples": 549, "dataset_name": "illustrated_ads"}}, "download_checksums": {"https://zenodo.org/record/5838410/files/images.zip?download=1": {"num_bytes": 48063000, "checksum": "05f1562bca55a44ff00ad52aec19b59ce10566d6d3d169ef75e0224e4a514295"}, "https://zenodo.org/record/5838410/files/ads.csv?download=1": {"num_bytes": 47362, "checksum": "001098f61be7630d985ffc61713c620a9a78518bda6f7ae569c43d37e032cccb"}, "https://zenodo.org/record/5838410/files/sample.csv?download=1": {"num_bytes": 876387, "checksum": "74f585434b9b644c30fbafe9ff400d52dbfb51d620551a23194ecf961db5d697"}}, "download_size": 48986749, "post_processing_size": null, "dataset_size": 773969, "size_in_bytes": 49760718}}
 
1
+ {"default": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"file": {"dtype": "string", "_type": "Value"}, "label": {"names": ["text-only", "illustrations"], "_type": "ClassLabel"}, "pub_date": {"dtype": "timestamp[ns]", "_type": "Value"}, "page_seq_num": {"dtype": "int64", "_type": "Value"}, "edition_seq_num": {"dtype": "int64", "_type": "Value"}, "batch": {"dtype": "string", "_type": "Value"}, "lccn": {"dtype": "string", "_type": "Value"}, "box": {"feature": {"dtype": "float32", "_type": "Value"}, "_type": "List"}, "score": {"dtype": "float64", "_type": "Value"}, "ocr": {"dtype": "string", "_type": "Value"}, "place_of_publication": {"dtype": "string", "_type": "Value"}, "geographic_coverage": {"dtype": "string", "_type": "Value"}, "name": {"dtype": "string", "_type": "Value"}, "publisher": {"dtype": "string", "_type": "Value"}, "url": {"dtype": "string", "_type": "Value"}, "page_url": {"dtype": "string", "_type": "Value"}, "image": {"_type": "Image"}}, "config_name": "default", "splits": {"train": {"name": "train", "num_bytes": 48233897, "num_examples": 549, "dataset_name": null}}, "download_size": 48045363, "dataset_size": 48233897, "size_in_bytes": 96279260}}
illustrated_ads.py DELETED
@@ -1,135 +0,0 @@
1
- # Copyright 2020 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
- """Dataset of illustrated and non illustrated 19th Century newspaper ads."""
15
-
16
- import ast
17
- import os
18
- import pandas as pd
19
- import datasets
20
-
21
- _CITATION = """\
22
- @dataset{van_strien_daniel_2021_5838410,
23
- author = {van Strien, Daniel},
24
- title = {{19th Century United States Newspaper Advert images
25
- with 'illustrated' or 'non illustrated' labels}},
26
- month = oct,
27
- year = 2021,
28
- publisher = {Zenodo},
29
- version = {0.0.1},
30
- doi = {10.5281/zenodo.5838410},
31
- url = {https://doi.org/10.5281/zenodo.5838410}}
32
- """
33
-
34
-
35
- _DESCRIPTION = """\
36
- The Dataset contains images derived from the Newspaper Navigator (news-navigator.labs.loc.gov/), a dataset of images drawn from the Library of Congress Chronicling America collection.
37
- """
38
-
39
- _HOMEPAGE = "https://doi.org/10.5281/zenodo.5838410"
40
-
41
- _LICENSE = "Public Domain"
42
-
43
-
44
- _URLS = "https://zenodo.org/record/5838410/files/images.zip?download=1"
45
-
46
- _DTYPES = {
47
- "page_seq_num": "int64",
48
- "edition_seq_num": "int64",
49
- "batch": "string",
50
- "lccn": "string",
51
- "score": "float64",
52
- "place_of_publication": "string",
53
- "name": "string",
54
- "publisher": "string",
55
- "url": "string",
56
- "page_url": "string",
57
- }
58
-
59
-
60
- class IllustratedAds(datasets.GeneratorBasedBuilder):
61
- """Illustated Historic Newspaper Ads datasets"""
62
-
63
- VERSION = datasets.Version("1.1.0")
64
-
65
- def _info(self):
66
-
67
- features = datasets.Features(
68
- {
69
- "file": datasets.Value("string"),
70
- "image": datasets.Image(),
71
- "label": datasets.ClassLabel(names=["text-only", "illustrations"]),
72
- "pub_date": datasets.Value("timestamp[ns]"),
73
- "page_seq_num": datasets.Value("int64"),
74
- "edition_seq_num": datasets.Value("int64"),
75
- "batch": datasets.Value("string"),
76
- "lccn": datasets.Value("string"),
77
- "box": datasets.Sequence(datasets.Value("float32")),
78
- "score": datasets.Value("float64"),
79
- "ocr": datasets.Value("string"),
80
- "place_of_publication": datasets.Value("string"),
81
- "geographic_coverage": datasets.Value("string"),
82
- "name": datasets.Value("string"),
83
- "publisher": datasets.Value("string"),
84
- "url": datasets.Value("string"),
85
- "page_url": datasets.Value("string"),
86
- }
87
- )
88
-
89
- return datasets.DatasetInfo(
90
- description=_DESCRIPTION,
91
- features=features,
92
- homepage=_HOMEPAGE,
93
- license=_LICENSE,
94
- citation=_CITATION,
95
- )
96
-
97
- def _split_generators(self, dl_manager):
98
- images = dl_manager.download_and_extract(_URLS)
99
- annotations = dl_manager.download(
100
- [
101
- "https://zenodo.org/record/5838410/files/ads.csv?download=1",
102
- "https://zenodo.org/record/5838410/files/sample.csv?download=1",
103
- ]
104
- )
105
- df_labels = pd.read_csv(annotations[0], index_col=0)
106
- df_metadata = pd.read_csv(
107
- annotations[1],
108
- index_col=0,
109
- dtype=_DTYPES,
110
- )
111
- df_metadata["file"] = df_metadata.filepath.str.replace("/", "_")
112
- df_metadata = df_metadata.set_index("file", drop=True)
113
- df = df_labels.join(df_metadata)
114
- df = df.reset_index()
115
- annotations = df.to_dict(orient="records")
116
- return [
117
- datasets.SplitGenerator(
118
- name=datasets.Split.TRAIN,
119
- gen_kwargs={
120
- "images": images,
121
- "annotations": annotations,
122
- },
123
- ),
124
- ]
125
-
126
- def _generate_examples(self, images, annotations):
127
- for id_, row in enumerate(annotations):
128
- box = ast.literal_eval(row["box"])
129
- row["box"] = box
130
- row.pop("filepath")
131
- ocr = " ".join(ast.literal_eval(row["ocr"]))
132
- row["ocr"] = ocr
133
- image = row["file"]
134
- row["image"] = os.path.join(images, image)
135
- yield id_, row