davanstrien HF staff commited on
Commit
c76f756
1 Parent(s): 34393a9

upload dataset script

Browse files
Files changed (2) hide show
  1. brill_iconclass.py +77 -0
  2. dataset_infos.json +1 -0
brill_iconclass.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Brill Iconclass AI Test Set data."""
15
+
16
+
17
+ import json
18
+ import os
19
+ from PIL import Image
20
+ import datasets
21
+
22
+ _CITATION = """\
23
+ @MISC{iconclass,
24
+ title = {Brill Iconclass AI Test Set},
25
+ author={Etienne Posthumus},
26
+ year={2020}
27
+ }
28
+ """
29
+
30
+
31
+ _DESCRIPTION = """\
32
+ A dataset for applying machine learning to collections described with the Iconclass classification system.
33
+ """
34
+
35
+ _HOMEPAGE = "https://labs.brill.com/ictestset/"
36
+
37
+ _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
38
+
39
+ _URL = "https://labs.brill.com/ictestset/779ba2ca9e977c58d818e3823a676973.zip"
40
+
41
+ class BrillIconclass(datasets.GeneratorBasedBuilder):
42
+ """Brill IconClass AI dataset"""
43
+
44
+ VERSION = datasets.Version("1.1.0")
45
+
46
+
47
+ def _info(self):
48
+ features = datasets.Features(
49
+ {
50
+ "image": datasets.Image(),
51
+ "label": [datasets.Value("string")]
52
+ }
53
+ )
54
+ return datasets.DatasetInfo(
55
+ description=_DESCRIPTION,
56
+ features=features,
57
+ homepage=_HOMEPAGE,
58
+ license=_LICENSE,
59
+ citation=_CITATION,
60
+ )
61
+
62
+ def _split_generators(self, dl_manager):
63
+ data_dir = dl_manager.download_and_extract(_URL)
64
+ return [
65
+ datasets.SplitGenerator(
66
+ name=datasets.Split.TRAIN,
67
+ gen_kwargs={"data_json": os.path.join(data_dir, "data.json"), "data_dir": data_dir},
68
+ ),
69
+ ]
70
+
71
+ def _generate_examples(self, data_json, data_dir):
72
+ with open(data_json, encoding="utf-8") as f:
73
+ data = json.load(f)
74
+ for row, item in enumerate(data.items()):
75
+ filepath, labels = item
76
+ image = Image.open(os.path.join(data_dir, filepath))
77
+ yield row, {"image": image, "label": labels}
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default": {"description": "A dataset for applying machine learning to collections described with the Iconclass classification system.\n", "citation": "@MISC{iconclass,\ntitle = {Brill Iconclass AI Test Set},\nauthor={Etienne Posthumus},\nyear={2020}\n}\n", "homepage": "https://labs.brill.com/ictestset/", "license": "https://creativecommons.org/publicdomain/zero/1.0/", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "label": [{"dtype": "string", "id": null, "_type": "Value"}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "brill_iconclass", "config_name": "default", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 19925506, "num_examples": 87744, "dataset_name": "brill_iconclass"}}, "download_checksums": {"https://labs.brill.com/ictestset/779ba2ca9e977c58d818e3823a676973.zip": {"num_bytes": 3295276816, "checksum": "96403cd3fdd34c71e4fa97078435350c244c9023af022cc3b8c2500cc13c684a"}}, "download_size": 3295276816, "post_processing_size": null, "dataset_size": 19925506, "size_in_bytes": 3315202322}}