Convert to parquet (loading scripts are no longer supported)

#2
by davanstrien HF Staff - opened
README.md CHANGED
@@ -19,17 +19,17 @@ dataset_info:
19
  - name: hash_id
20
  dtype: string
21
  - name: titles
22
- sequence:
23
  - name: id
24
- dtype: int64
25
  - name: name
26
- dtype: string
27
  - name: creators
28
- sequence:
29
  - name: id
30
- dtype: int64
31
  - name: name
32
- dtype: string
33
  - name: location
34
  dtype: string
35
  - name: institution
@@ -45,33 +45,38 @@ dataset_info:
45
  - name: path
46
  dtype: string
47
  - name: tags
48
- sequence:
49
  - name: id
50
- dtype: int64
51
  - name: name
52
- dtype: string
53
  - name: language
54
- dtype: string
55
  - name: count
56
- dtype: int64
57
  - name: regions
58
- sequence:
59
  - name: x
60
- dtype: float64
61
  - name: y
62
- dtype: float64
63
  - name: width
64
- dtype: float64
65
  - name: height
66
- dtype: float64
67
  - name: image
68
  dtype: image
69
  splits:
70
  - name: train
71
- num_bytes: 269611482
72
  num_examples: 60633
73
- download_size: 5625395643
74
- dataset_size: 269611482
 
 
 
 
 
75
  ---
76
 
77
  # ARTigo: Social Image Tagging
@@ -94,8 +99,15 @@ Measured on that deposit: 270,024 distinct tags, 4.9M tag–image pairs, and jus
94
 
95
  Metadata coverage is partial: `creators` is empty on 12,182 records (20%), `institution` on 13,687 (22%), `location` on 17,795 (29%). Tags are unedited — the depositors deliberately left player spelling errors uncorrected rather than risk mangling specialist art-historical vocabulary.
96
 
97
- > [!WARNING]
98
- > The repo still ships a legacy Python loading script, which `datasets` no longer runs (`RuntimeError: Dataset scripts are no longer supported`). Until it is converted to Parquet, work from the Zenodo deposit.
 
 
 
 
 
 
 
99
 
100
  ## The tags are overwhelmingly German
101
 
 
19
  - name: hash_id
20
  dtype: string
21
  - name: titles
22
+ struct:
23
  - name: id
24
+ list: int64
25
  - name: name
26
+ list: string
27
  - name: creators
28
+ struct:
29
  - name: id
30
+ list: int64
31
  - name: name
32
+ list: string
33
  - name: location
34
  dtype: string
35
  - name: institution
 
45
  - name: path
46
  dtype: string
47
  - name: tags
48
+ struct:
49
  - name: id
50
+ list: int64
51
  - name: name
52
+ list: string
53
  - name: language
54
+ list: string
55
  - name: count
56
+ list: int64
57
  - name: regions
58
+ list:
59
  - name: x
60
+ list: float64
61
  - name: y
62
+ list: float64
63
  - name: width
64
+ list: float64
65
  - name: height
66
+ list: float64
67
  - name: image
68
  dtype: image
69
  splits:
70
  - name: train
71
+ num_bytes: 5905082165
72
  num_examples: 60633
73
+ download_size: 11451421751
74
+ dataset_size: 5905082165
75
+ configs:
76
+ - config_name: default
77
+ data_files:
78
+ - split: train
79
+ path: data/train-*
80
  ---
81
 
82
  # ARTigo: Social Image Tagging
 
99
 
100
  Metadata coverage is partial: `creators` is empty on 12,182 records (20%), `institution` on 13,687 (22%), `location` on 17,795 (29%). Tags are unedited — the depositors deliberately left player spelling errors uncorrected rather than risk mangling specialist art-historical vocabulary.
101
 
102
+ ```python
103
+ from datasets import load_dataset
104
+
105
+ ds = load_dataset("biglam/artigo", split="train")
106
+ row = ds[0]
107
+ row["image"] # the artwork
108
+ row["tags"]["name"] # tags are stored column-wise, not as a list of dicts
109
+ row["tags"]["language"] # tag language, mostly de
110
+ ```
111
 
112
  ## The tags are overwhelmingly German
113
 
artigo.py DELETED
@@ -1,167 +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
-
15
- """Script for reading the dataset of the 'ARTigo: Social Image Tagging' project."""
16
-
17
- import glob
18
- import json
19
- import datasets
20
- import requests
21
-
22
- from PIL import Image
23
- from pathlib import Path
24
-
25
- _CITATION = """\
26
- @dataset{bry_et_al_artigo,
27
- author = {Bry, François and
28
- Kohle, Hubertus and
29
- Krefeld, Thomas and
30
- Riepl, Christian and
31
- Schneider, Stefanie and
32
- Schön, Gerhard and
33
- Schulz, Klaus},
34
- title = {{ARTigo}: Social Image Tagging (Aggregated Data)},
35
- publisher = {Zenodo},
36
- doi = {10.5281/zenodo.8202331},
37
- url = {https://doi.org/10.5281/zenodo.8202331}}
38
- """
39
-
40
- _DESCRIPTION = """\
41
- ARTigo (https://www.artigo.org/) is a Citizen Science project that has been jointly developed at the Institute for Art History and the Institute for Informatics at Ludwig Maximilian University of Munich since 2010. It enables participants to engage in the tagging of artworks, thus fostering knowledge accumulation and democratizing access to a traditionally elitist field. ARTigo is built as an interactive web application that offers Games With a Purpose: in them, players are presented with an image – and then challenged to communicate with one another using visual or textual annotations within a given time. Through this playful approach, the project aims to inspire greater appreciation for art and draw new audiences to museums and archives. It streamlines the discoverability of art-historical images, while promoting inclusivity, effective communication, and collaborative research practices. The project’s data are freely available to the wider research community for novel scientific investigations.
42
- """
43
-
44
- _HOMEPAGE = "https://doi.org/10.5281/zenodo.8202331"
45
-
46
- _LICENSE = "Creative Commons Attribution Share Alike 4.0 International (CC BY-SA 4.0)"
47
-
48
- _URLS = "https://zenodo.org/api/records/8202331"
49
-
50
-
51
- logger = datasets.utils.logging.get_logger(__name__)
52
-
53
-
54
- def create_annotations_dict(annotations_file):
55
- annotations = {}
56
-
57
- with open(annotations_file, encoding="utf-8") as annotations_obj:
58
- for annotation_row in annotations_obj:
59
- annotation_data = json.loads(annotation_row, strict=False)
60
- for tag in annotation_data["tags"]:
61
- if not tag.get("regions"):
62
- tag["regions"] = None
63
- annotations[annotation_data["hash_id"]] = annotation_data
64
-
65
- return annotations
66
-
67
-
68
- class ARTigo(datasets.GeneratorBasedBuilder):
69
- """Dataset of the 'ARTigo: Social Image Tagging' project"""
70
-
71
- ZENODO_RECORD = requests.get(_URLS).json()
72
- VERSION = datasets.Version(f"{ZENODO_RECORD['metadata']['version']}.0")
73
-
74
- def _info(self):
75
- features = datasets.Features(
76
- {
77
- "id": datasets.Value("int64"),
78
- "hash_id": datasets.Value("string"),
79
- "titles": datasets.Sequence(
80
- {
81
- "id": datasets.Value("int64"),
82
- "name": datasets.Value("string"),
83
- }
84
- ),
85
- "creators": datasets.Sequence(
86
- {
87
- "id": datasets.Value("int64"),
88
- "name": datasets.Value("string"),
89
- }
90
- ),
91
- "location": datasets.Value("string"),
92
- "institution": datasets.Value("string"),
93
- "source": {
94
- "id": datasets.Value("int64"),
95
- "name": datasets.Value("string"),
96
- "url": datasets.Value("string"),
97
- },
98
- "path": datasets.Value("string"),
99
- "tags": datasets.Sequence(
100
- {
101
- "id": datasets.Value("int64"),
102
- "name": datasets.Value("string"),
103
- "language": datasets.Value("string"),
104
- "count": datasets.Value("int64"),
105
- "regions": datasets.Sequence(
106
- {
107
- "x": datasets.Value("float64"),
108
- "y": datasets.Value("float64"),
109
- "width": datasets.Value("float64"),
110
- "height": datasets.Value("float64"),
111
- }
112
- ),
113
- }
114
- ),
115
- "image": datasets.Image(),
116
- }
117
- )
118
-
119
- return datasets.DatasetInfo(
120
- description=_DESCRIPTION,
121
- features=features,
122
- homepage=_HOMEPAGE,
123
- license=_LICENSE,
124
- citation=_CITATION,
125
- )
126
-
127
- def _split_generators(self, dl_manager):
128
- image_urls = [
129
- file["links"]["self"]
130
- for file in self.ZENODO_RECORD['files']
131
- if file["type"] == "zip"
132
- ]
133
- annotation_urls = [
134
- file["links"]["self"]
135
- for file in self.ZENODO_RECORD['files']
136
- if file["type"] == "jsonl"
137
- ]
138
-
139
- image_directories = dl_manager.download_and_extract(image_urls)
140
- annotations_file = dl_manager.download(annotation_urls)[0]
141
-
142
- return [
143
- datasets.SplitGenerator(
144
- name=datasets.Split.TRAIN,
145
- gen_kwargs={
146
- "image_directories": image_directories,
147
- "annotations_file": annotations_file,
148
- },
149
- ),
150
- ]
151
-
152
- def _generate_examples(self, image_directories, annotations_file):
153
- annotations = create_annotations_dict(annotations_file)
154
-
155
- for image_directory in image_directories:
156
- for image_file in glob.glob(f"{image_directory}/**/*.jpg", recursive=True):
157
- with Image.open(image_file) as image:
158
- try:
159
- hash_id, _ = Path(image_file).name.split('.', 1)
160
- image_data = annotations[hash_id]
161
- image_data["image"] = image
162
-
163
- yield image_data["id"], image_data
164
- except Exception:
165
- logger.warn(Path(image_file).name)
166
-
167
- continue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/train-00000-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d55491dd7aae58f064e82359b9965482323a56904301709b3efffae17107ebeb
3
+ size 480318349
data/train-00001-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fdaacd4dfcf00a6e05e82dd05a65093367205a853e8e549fd3e403597fa9d9e
3
+ size 483339370
data/train-00002-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:167e30a3b4baef0e07627641c496aa99f4fd226336a7b3221aa2a6f285b6c133
3
+ size 484973156
data/train-00003-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bc2718ed012eef477abfa8bca583207ba0cee62523052c1a156de8136c9a628
3
+ size 481426190
data/train-00004-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:159681c802de6063469bf574da27ff94e8d09de19eb0169a50ea5996cda557ca
3
+ size 489225268
data/train-00005-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d4e082c9e20cf34bbb5c340614f4f3b10aaab422e0fb247dd2d2a399c8ea722
3
+ size 489985566
data/train-00006-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae48bb74f838af0f1a952fa3ed7aa60485baf10bc3f9a3b733dd5bec40816205
3
+ size 485819390
data/train-00007-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef7612a616ba689f1bb18b47c24a704d5ec406cc47bc3cf65989619e73d0a7a3
3
+ size 482762820
data/train-00008-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bdd45b58cbd7a23da55ba3e29ac7d7420f8875e159bab75973ed867a40345ae
3
+ size 484500222
data/train-00009-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:838ae0c2509261308fd8eda6de4aa3685587bddfc450084c43b363a06f5f66c1
3
+ size 489055597
data/train-00010-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c320194dc12bf54e08545ef87551c7423cd11c4d04487eda5161279b1938a5a3
3
+ size 484014370
data/train-00011-of-00012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0adb269c7f2612b3e2c8b475a875898c627c7b1dd3930eb148bd0b65f4e212a
3
+ size 490605810