stefanieschneider commited on
Commit
4e0faec
1 Parent(s): c97dafd

Initial commit

Browse files
Files changed (2) hide show
  1. README.md +132 -0
  2. artigo.py +168 -0
README.md CHANGED
@@ -1,3 +1,135 @@
1
  ---
 
 
2
  license: cc-by-sa-4.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ annotations_creators:
3
+ - crowd-generated
4
  license: cc-by-sa-4.0
5
+ language:
6
+ - de
7
+ - en
8
+ - fr
9
+ tags:
10
+ - lam
11
+ task_categories:
12
+ - object-detection
13
+ - image-classification
14
+ pretty_name: 'ARTigo: Social Image Tagging'
15
  ---
16
+
17
+ # Dataset Card for ARTigo: Social Image Tagging
18
+
19
+ ## Table of Contents
20
+
21
+ - [Table of Contents](#table-of-contents)
22
+ - [Dataset Description](#dataset-description)
23
+ - [Dataset Summary](#dataset-summary)
24
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
25
+ - [Dataset Structure](#dataset-structure)
26
+ - [Data Instances](#data-instances)
27
+ - [Data Fields](#data-fields)
28
+ - [Data Splits](#data-splits)
29
+ - [Additional Information](#additional-information)
30
+ - [Licensing Information](#licensing-information)
31
+ - [Citation Information](#citation-information)
32
+
33
+ ## Dataset Description
34
+
35
+ ### Dataset Summary
36
+
37
+ 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, *tags*, 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.
38
+
39
+ ### Supported Tasks and Leaderboards
40
+
41
+ - `object-detection`: This dataset can be used to train models for object detection tasks on art-historical images.
42
+ - `image-classification`: This dataset can also be used for image classification tasks by using only the tags and not the associated region information.
43
+
44
+ ## Dataset Structure
45
+
46
+ This dataset has a single configuration.
47
+
48
+ ### Data Instances
49
+
50
+ An example instance from this dataset:
51
+
52
+ ```python
53
+ {
54
+ 'id': 32254,
55
+ 'hash_id': 'e34fa90bf4c73d20ac19b14fa615206e',
56
+ 'titles': {
57
+ 'id': [10893],
58
+ 'name': ['Entwurf für ein zwölfteiliges Kartenspiel']
59
+ },
60
+ 'creators': {
61
+ 'id': [2391],
62
+ 'name': ['Félix Vallotton']
63
+ },
64
+ 'location': 'Lausanne',
65
+ 'institution': 'Galerie du Chêne',
66
+ 'source': {
67
+ 'id': 2,
68
+ 'name': 'Artemis',
69
+ 'url': 'http://artemis.uni-muenchen.de/'
70
+ },
71
+ 'path': 'https://api.artigo.org/media/e3/4f/e34fa90bf4c73d20ac19b14fa615206e.jpg',
72
+ 'tags': {
73
+ 'id': [6, 10, 13, ..., 206331],
74
+ 'name': ['blau', 'feder', 'flügel', ..., 'herzober'],
75
+ 'language': ['de', 'de', 'de', ..., 'de'],
76
+ 'count': [16, 6, 6, ..., 1],
77
+ 'regions': [None, None, None, ..., None]
78
+ },
79
+ 'image': <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=381x600 at 0x7FEF3A415820>
80
+ }
81
+ ```
82
+
83
+ ### Data Fields
84
+
85
+ The dataset contains ten fields:
86
+
87
+ - `id`: a unique identifier for the image;
88
+ - `hash_id`: a unique identifier for the image based on its content (e.g., image hash);
89
+ - `titles`: a list of titles associated with the image, with each title having the following key-value pairs:
90
+ - `id`: a unique identifier for the title;
91
+ - `name`: the name of the title;
92
+ - `creators`: a list of creators associated with the image, with each creator having the following key-value pairs:
93
+ - `id`: a unique identifier for the creator;
94
+ - `name`: the name of the creator;
95
+ - `location`: the location associated with the image;
96
+ - `institution`: the institution that holds the image;
97
+ - `source`: information about the source of the image, with the following key-value pairs:
98
+ - `id`: a unique identifier for the source;
99
+ - `name`: the name of the source;
100
+ - `url`: the URL of the source;
101
+ - `path`: the path to the image file;
102
+ - `tags`: a list of tags associated with the image, with each tag having the following key-value pairs:
103
+ - `id`: a unique identifier for the tag;
104
+ - `name`: the name of the tag;
105
+ - `language`: the language of the tag (if available);
106
+ - `count`: the number of times the tag has been applied to the image;
107
+ - `regions`: the regions of the image to which the tag can be applied (if available);
108
+ - `image`: the image.
109
+
110
+ ### Data Splits
111
+
112
+ The dataset doesn't provide any predefined train, validation or test splits.
113
+
114
+ ## Additional Information
115
+
116
+ ### Licensing Information
117
+
118
+ [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
119
+
120
+ ### Citation Information
121
+
122
+ ```
123
+ @dataset{bry_et_al_artigo,
124
+ author = {Bry, François and
125
+ Kohle, Hubertus and
126
+ Krefeld, Thomas and
127
+ Riepl, Christian and
128
+ Schneider, Stefanie and
129
+ Schön, Gerhard and
130
+ Schulz, Klaus},
131
+ title = {{ARTigo}: Social Image Tagging (Aggregated Data)},
132
+ publisher = {Zenodo},
133
+ doi = {10.5281/zenodo.8202331},
134
+ url = {https://doi.org/10.5281/zenodo.8202331}}
135
+ ```
artigo.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ VERSION = datasets.Version("1.0.0")
72
+
73
+ def _info(self):
74
+ features = datasets.Features(
75
+ {
76
+ "id": datasets.Value("int64"),
77
+ "hash_id": datasets.Value("string"),
78
+ "titles": datasets.Sequence(
79
+ {
80
+ "id": datasets.Value("int64"),
81
+ "name": datasets.Value("string"),
82
+ }
83
+ ),
84
+ "creators": datasets.Sequence(
85
+ {
86
+ "id": datasets.Value("int64"),
87
+ "name": datasets.Value("string"),
88
+ }
89
+ ),
90
+ "location": datasets.Value("string"),
91
+ "institution": datasets.Value("string"),
92
+ "source": {
93
+ "id": datasets.Value("int64"),
94
+ "name": datasets.Value("string"),
95
+ "url": datasets.Value("string"),
96
+ },
97
+ "path": datasets.Value("string"),
98
+ "tags": datasets.Sequence(
99
+ {
100
+ "id": datasets.Value("int64"),
101
+ "name": datasets.Value("string"),
102
+ "language": datasets.Value("string"),
103
+ "count": datasets.Value("int64"),
104
+ "regions": datasets.Sequence(
105
+ {
106
+ "x": datasets.Value("float64"),
107
+ "y": datasets.Value("float64"),
108
+ "width": datasets.Value("float64"),
109
+ "height": datasets.Value("float64"),
110
+ }
111
+ ),
112
+ }
113
+ ),
114
+ "image": datasets.Image(),
115
+ }
116
+ )
117
+
118
+ return datasets.DatasetInfo(
119
+ description=_DESCRIPTION,
120
+ features=features,
121
+ homepage=_HOMEPAGE,
122
+ license=_LICENSE,
123
+ citation=_CITATION,
124
+ )
125
+
126
+ def _split_generators(self, dl_manager):
127
+ zenodo_record = requests.get(_URLS).json()
128
+
129
+ image_urls = [
130
+ file["links"]["self"]
131
+ for file in zenodo_record['files']
132
+ if file["type"] == "zip"
133
+ ]
134
+ annotation_urls = [
135
+ file["links"]["self"]
136
+ for file in zenodo_record['files']
137
+ if file["type"] == "jsonl"
138
+ ]
139
+
140
+ image_directories = dl_manager.download_and_extract(image_urls)
141
+ annotations_file = dl_manager.download(annotation_urls)[0]
142
+
143
+ return [
144
+ datasets.SplitGenerator(
145
+ name=datasets.Split.TRAIN,
146
+ gen_kwargs={
147
+ "image_directories": image_directories,
148
+ "annotations_file": annotations_file,
149
+ },
150
+ ),
151
+ ]
152
+
153
+ def _generate_examples(self, image_directories, annotations_file):
154
+ annotations = create_annotations_dict(annotations_file)
155
+
156
+ for image_directory in image_directories:
157
+ for image_file in glob.glob(f"{image_directory}/**/*.jpg", recursive=True):
158
+ with Image.open(image_file) as image:
159
+ try:
160
+ hash_id, _ = Path(image_file).name.split('.', 1)
161
+ image_data = annotations[hash_id]
162
+ image_data["image"] = image
163
+
164
+ yield image_data["id"], image_data
165
+ except Exception:
166
+ logger.warn(image_file.name)
167
+
168
+ continue