davanstrien HF staff commited on
Commit
9a691ef
·
1 Parent(s): 1899b39
Files changed (2) hide show
  1. README.md +3 -3
  2. dating-historical-color-images.py +102 -6
README.md CHANGED
@@ -14,8 +14,8 @@ dataset_info:
14
  '4': 1970s
15
  splits:
16
  - name: train
17
- num_bytes: 329016
18
- num_examples: 1326
19
  download_size: 222265856
20
- dataset_size: 329016
21
  ---
 
14
  '4': 1970s
15
  splits:
16
  - name: train
17
+ num_bytes: 48014028
18
+ num_examples: 1325
19
  download_size: 222265856
20
+ dataset_size: 48014028
21
  ---
dating-historical-color-images.py CHANGED
@@ -15,6 +15,8 @@
15
 
16
  from pathlib import Path
17
  import datasets
 
 
18
 
19
  _CITATION = """@inproceedings{10.1007/978-3-642-33783-3_36,
20
  author = {Palermo, Frank and Hays, James and Efros, Alexei A.},
@@ -69,17 +71,111 @@ class IllustratedAds(datasets.GeneratorBasedBuilder):
69
  )
70
 
71
  def _split_generators(self, dl_manager):
72
- images = dl_manager.download_and_extract(_URLS)
73
  return [
74
  datasets.SplitGenerator(
75
  name=datasets.Split.TRAIN,
76
- gen_kwargs={"images": images},
77
  ),
78
  ]
79
 
80
- def _generate_examples(self, images):
81
- images = Path(images).rglob("*.jpg")
82
- for id_, image in enumerate(images):
83
- image = str(image)
 
 
84
  label = str(Path(image).parts[-2])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  yield id_, {"image": image, "label": label}
 
15
 
16
  from pathlib import Path
17
  import datasets
18
+ from PIL import Image
19
+ import io
20
 
21
  _CITATION = """@inproceedings{10.1007/978-3-642-33783-3_36,
22
  author = {Palermo, Frank and Hays, James and Efros, Alexei A.},
 
71
  )
72
 
73
  def _split_generators(self, dl_manager):
74
+ images = dl_manager.download(_URLS)
75
  return [
76
  datasets.SplitGenerator(
77
  name=datasets.Split.TRAIN,
78
+ gen_kwargs={"archive": dl_manager.iter_archive(images)},
79
  ),
80
  ]
81
 
82
+ def _generate_examples(self, archive):
83
+ id_ = 0
84
+ for fname, _ in archive:
85
+ if Path(fname).suffix != ".jpg":
86
+ continue
87
+ image = Image.open(fname)
88
  label = str(Path(image).parts[-2])
89
+ id_ += 1
90
+ yield id_, {"image": image, "label": label}
91
+
92
+
93
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
94
+ #
95
+ # Licensed under the Apache License, Version 2.0 (the "License");
96
+ # you may not use this file except in compliance with the License.
97
+ # You may obtain a copy of the License at
98
+ #
99
+ # http://www.apache.org/licenses/LICENSE-2.0
100
+ #
101
+ # Unless required by applicable law or agreed to in writing, software
102
+ # distributed under the License is distributed on an "AS IS" BASIS,
103
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104
+ # See the License for the specific language governing permissions and
105
+ # limitations under the License.
106
+ """Dataset for dating historical color images"""
107
+
108
+ from pathlib import Path
109
+ import datasets
110
+ from PIL import Image
111
+
112
+ _CITATION = """@inproceedings{10.1007/978-3-642-33783-3_36,
113
+ author = {Palermo, Frank and Hays, James and Efros, Alexei A.},
114
+ title = {Dating Historical Color Images},
115
+ year = {2012},
116
+ isbn = {9783642337826},
117
+ publisher = {Springer-Verlag},
118
+ address = {Berlin, Heidelberg},
119
+ url = {https://doi.org/10.1007/978-3-642-33783-3_36},
120
+ doi = {10.1007/978-3-642-33783-3_36},
121
+ abstract = {We introduce the task of automatically estimating the age of historical color photographs. We suggest features which attempt to capture temporally discriminative information based on the evolution of color imaging processes over time and evaluate the performance of both these novel features and existing features commonly utilized in other problem domains on a novel historical image data set. For the challenging classification task of sorting historical color images into the decade during which they were photographed, we demonstrate significantly greater accuracy than that shown by untrained humans on the same data set. Additionally, we apply the concept of data-driven camera response function estimation to historical color imagery, demonstrating its relevance to both the age estimation task and the popular application of imitating the appearance of vintage color photography.},
122
+ booktitle = {Proceedings of the 12th European Conference on Computer Vision - Volume Part VI},
123
+ pages = {499–512},
124
+ numpages = {14},
125
+ location = {Florence, Italy},
126
+ series = {ECCV'12}
127
+ }
128
+ """
129
+
130
+
131
+ _DESCRIPTION = """\
132
+ This dataset contains color photographs taken between the 1930s and 1970s.
133
+ The goal of the dataset is to develop methods for dating historical color photographs
134
+ """
135
+
136
+ _HOMEPAGE = "http://graphics.cs.cmu.edu/projects/historicalColor/"
137
+
138
+
139
+ _URLS = "http://graphics.cs.cmu.edu/projects/historicalColor/HistoricalColor-ECCV2012-DecadeDatabase.tar"
140
+
141
+
142
+ class IllustratedAds(datasets.GeneratorBasedBuilder):
143
+ """Dating Historical Color Images dataset"""
144
+
145
+ VERSION = datasets.Version("1.1.0")
146
+
147
+ def _info(self):
148
+ features = datasets.Features(
149
+ {
150
+ "image": datasets.Image(),
151
+ "label": datasets.ClassLabel(
152
+ names=["1930s", "1940s", "1950s", "1960s", "1970s"]
153
+ ),
154
+ }
155
+ )
156
+
157
+ return datasets.DatasetInfo(
158
+ description=_DESCRIPTION,
159
+ features=features,
160
+ homepage=_HOMEPAGE,
161
+ citation=_CITATION,
162
+ )
163
+
164
+ def _split_generators(self, dl_manager):
165
+ images = dl_manager.download(_URLS)
166
+ return [
167
+ datasets.SplitGenerator(
168
+ name=datasets.Split.TRAIN,
169
+ gen_kwargs={"archive": dl_manager.iter_archive(images)},
170
+ ),
171
+ ]
172
+
173
+ def _generate_examples(self, archive):
174
+ id_ = 0
175
+ for fname, fobject in archive:
176
+ if Path(fname).suffix != ".jpg":
177
+ continue
178
+ image = Image.open(io.BytesIO(fobject.read()))
179
+ label = str(Path(fname).parts[-2])
180
+ id_ += 1
181
  yield id_, {"image": image, "label": label}