Eugene Siow commited on
Commit
600666e
1 Parent(s): 6ac4e0a
BSD100.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """BSD100 dataset: An evaluation dataset for the image super resolution task"""
16
+
17
+
18
+ import datasets
19
+ from pathlib import Path
20
+
21
+
22
+ _CITATION = """
23
+ @inproceedings{martin2001database,
24
+ title={A database of human segmented natural images and its application to evaluating segmentation algorithms and measuring ecological statistics},
25
+ author={Martin, David and Fowlkes, Charless and Tal, Doron and Malik, Jitendra},
26
+ booktitle={Proceedings Eighth IEEE International Conference on Computer Vision. ICCV 2001},
27
+ volume={2},
28
+ pages={416--423},
29
+ year={2001},
30
+ organization={IEEE}
31
+ }
32
+ """
33
+
34
+ _DESCRIPTION = """
35
+ BSD is a dataset used frequently for image denoising and super-resolution.
36
+ BSD100 is the testing set of the Berkeley segmentation dataset BSD300.
37
+ """
38
+
39
+ _HOMEPAGE = "https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/"
40
+
41
+ _LICENSE = "UNK"
42
+
43
+ _DL_URL = "https://huggingface.co/datasets/eugenesiow/BSD100/resolve/main/data/"
44
+
45
+ _DEFAULT_CONFIG = "bicubic_x2"
46
+
47
+ _DATA_OPTIONS = {
48
+ "bicubic_x2": {
49
+ "hr": _DL_URL + "BSD100_HR.tar.gz",
50
+ "lr": _DL_URL + "BSD100_LR_x2.tar.gz",
51
+ },
52
+ "bicubic_x3": {
53
+ "hr": _DL_URL + "BSD100_HR.tar.gz",
54
+ "lr": _DL_URL + "BSD100_LR_x3.tar.gz",
55
+ },
56
+ "bicubic_x4": {
57
+ "hr": _DL_URL + "BSD100_HR.tar.gz",
58
+ "lr": _DL_URL + "BSD100_LR_x4.tar.gz",
59
+ }
60
+ }
61
+
62
+
63
+ class Bsd100Config(datasets.BuilderConfig):
64
+ """BuilderConfig for BSD100."""
65
+
66
+ def __init__(
67
+ self,
68
+ name,
69
+ hr_url,
70
+ lr_url,
71
+ **kwargs,
72
+ ):
73
+ if name not in _DATA_OPTIONS:
74
+ raise ValueError("data must be one of %s" % _DATA_OPTIONS)
75
+ super(Bsd100Config, self).__init__(name=name, version=datasets.Version("1.0.0"), **kwargs)
76
+ self.hr_url = hr_url
77
+ self.lr_url = lr_url
78
+
79
+
80
+ class Bsd100(datasets.GeneratorBasedBuilder):
81
+ """BSD100 dataset for single image super resolution evaluation."""
82
+
83
+ BUILDER_CONFIGS = [
84
+ Bsd100Config(
85
+ name=key,
86
+ hr_url=values['hr'],
87
+ lr_url=values['lr']
88
+ ) for key, values in _DATA_OPTIONS.items()
89
+ ]
90
+
91
+ DEFAULT_CONFIG_NAME = _DEFAULT_CONFIG
92
+
93
+ def _info(self):
94
+ features = datasets.Features(
95
+ {
96
+ "hr": datasets.Value("string"),
97
+ "lr": datasets.Value("string"),
98
+ }
99
+ )
100
+ return datasets.DatasetInfo(
101
+ description=_DESCRIPTION,
102
+ features=features,
103
+ supervised_keys=None,
104
+ homepage=_HOMEPAGE,
105
+ license=_LICENSE,
106
+ citation=_CITATION,
107
+ )
108
+
109
+ def _split_generators(self, dl_manager):
110
+ """Returns SplitGenerators."""
111
+ hr_data_dir = dl_manager.download_and_extract(self.config.hr_url)
112
+ lr_data_dir = dl_manager.download_and_extract(self.config.lr_url)
113
+ return [
114
+ datasets.SplitGenerator(
115
+ name=datasets.Split.VALIDATION,
116
+ # These kwargs will be passed to _generate_examples
117
+ gen_kwargs={
118
+ "lr_path": lr_data_dir,
119
+ "hr_path": str(Path(hr_data_dir) / 'BSD100_HR')
120
+ },
121
+ )
122
+ ]
123
+
124
+ def _generate_examples(
125
+ self, hr_path, lr_path
126
+ ):
127
+ """ Yields examples as (key, example) tuples. """
128
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
129
+ # The `key` is here for legacy reason (tfds) and is not important in itself.
130
+ extensions = {'.png'}
131
+ for file_path in sorted(Path(lr_path).glob("**/*")):
132
+ if file_path.suffix in extensions:
133
+ file_path_str = str(file_path.as_posix())
134
+ yield file_path_str, {
135
+ 'lr': file_path_str,
136
+ 'hr': str((Path(hr_path) / file_path.name).as_posix())
137
+ }
README.md ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - machine-generated
4
+ language_creators:
5
+ - found
6
+ languages: []
7
+ licenses:
8
+ - other-academic-use
9
+ multilinguality:
10
+ - monolingual
11
+ pretty_name: BSD100
12
+ size_categories:
13
+ - unknown
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - other
18
+ task_ids:
19
+ - other-other-image-super-resolution
20
+ ---
21
+
22
+ # Dataset Card for BSD100
23
+
24
+ ## Table of Contents
25
+ - [Table of Contents](#table-of-contents)
26
+ - [Dataset Description](#dataset-description)
27
+ - [Dataset Summary](#dataset-summary)
28
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
29
+ - [Languages](#languages)
30
+ - [Dataset Structure](#dataset-structure)
31
+ - [Data Instances](#data-instances)
32
+ - [Data Fields](#data-fields)
33
+ - [Data Splits](#data-splits)
34
+ - [Dataset Creation](#dataset-creation)
35
+ - [Curation Rationale](#curation-rationale)
36
+ - [Source Data](#source-data)
37
+ - [Annotations](#annotations)
38
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
39
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
40
+ - [Social Impact of Dataset](#social-impact-of-dataset)
41
+ - [Discussion of Biases](#discussion-of-biases)
42
+ - [Other Known Limitations](#other-known-limitations)
43
+ - [Additional Information](#additional-information)
44
+ - [Dataset Curators](#dataset-curators)
45
+ - [Licensing Information](#licensing-information)
46
+ - [Citation Information](#citation-information)
47
+ - [Contributions](#contributions)
48
+
49
+ ## Dataset Description
50
+
51
+ - **Homepage**: https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/
52
+ - **Repository**: https://huggingface.co/datasets/eugenesiow/BSD100
53
+ - **Paper**: https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=937655
54
+ - **Leaderboard**: https://github.com/eugenesiow/super-image#scale-x2
55
+
56
+ ### Dataset Summary
57
+
58
+ BSD is a dataset used frequently for image denoising and super-resolution. Of the subdatasets, BSD100 is aclassical image dataset having 100 test images proposed by [Martin et al. (2001)](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=937655). The dataset is composed of a large variety of images ranging from natural images to object-specific such as plants, people, food etc. BSD100 is the testing set of the Berkeley segmentation dataset BSD300.
59
+
60
+ Install with `pip`:
61
+ ```bash
62
+ pip install datasets super-image
63
+ ```
64
+
65
+ Evaluate a model with the [`super-image`](https://github.com/eugenesiow/super-image) library:
66
+ ```python
67
+ from datasets import load_dataset
68
+ from super_image import EdsrModel
69
+ from super_image.data import EvalDataset, EvalMetrics
70
+
71
+ dataset = load_dataset('eugenesiow/BSD100', 'bicubic_x2', split='validation')
72
+ eval_dataset = EvalDataset(dataset)
73
+ model = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=2)
74
+ EvalMetrics().evaluate(model, eval_dataset)
75
+ ```
76
+
77
+ ### Supported Tasks and Leaderboards
78
+
79
+ The dataset is commonly used for evaluation of the `image-super-resolution` task.
80
+
81
+ Unofficial [`super-image`](https://github.com/eugenesiow/super-image) leaderboard for:
82
+ - [Scale 2](https://github.com/eugenesiow/super-image#scale-x2)
83
+ - [Scale 3](https://github.com/eugenesiow/super-image#scale-x3)
84
+ - [Scale 4](https://github.com/eugenesiow/super-image#scale-x4)
85
+ - [Scale 8](https://github.com/eugenesiow/super-image#scale-x8)
86
+
87
+ ### Languages
88
+
89
+ Not applicable.
90
+
91
+ ## Dataset Structure
92
+
93
+ ### Data Instances
94
+
95
+ An example of `validation` for `bicubic_x2` looks as follows.
96
+ ```
97
+ {
98
+ "hr": "/.cache/huggingface/datasets/downloads/extracted/BSD100_HR/3096.png",
99
+ "lr": "/.cache/huggingface/datasets/downloads/extracted/BSD100_LR_x2/3096.png"
100
+ }
101
+ ```
102
+
103
+ ### Data Fields
104
+
105
+ The data fields are the same among all splits.
106
+
107
+ - `hr`: a `string` to the path of the High Resolution (HR) `.png` image.
108
+ - `lr`: a `string` to the path of the Low Resolution (LR) `.png` image.
109
+
110
+ ### Data Splits
111
+
112
+ | name |validation|
113
+ |-------|---:|
114
+ |bicubic_x2|100|
115
+ |bicubic_x3|100|
116
+ |bicubic_x4|100|
117
+
118
+
119
+ ## Dataset Creation
120
+
121
+ ### Curation Rationale
122
+
123
+ [More Information Needed]
124
+
125
+ ### Source Data
126
+
127
+ #### Initial Data Collection and Normalization
128
+
129
+ [More Information Needed]
130
+
131
+ #### Who are the source language producers?
132
+
133
+ [More Information Needed]
134
+
135
+ ### Annotations
136
+
137
+ #### Annotation process
138
+
139
+ No annotations.
140
+
141
+ #### Who are the annotators?
142
+
143
+ No annotators.
144
+
145
+ ### Personal and Sensitive Information
146
+
147
+ [More Information Needed]
148
+
149
+ ## Considerations for Using the Data
150
+
151
+ ### Social Impact of Dataset
152
+
153
+ [More Information Needed]
154
+
155
+ ### Discussion of Biases
156
+
157
+ [More Information Needed]
158
+
159
+ ### Other Known Limitations
160
+
161
+ [More Information Needed]
162
+
163
+ ## Additional Information
164
+
165
+ ### Dataset Curators
166
+
167
+ - **Original Authors**: [Martin et al. (2001)](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=937655)
168
+
169
+ ### Licensing Information
170
+
171
+ You are free to download a portion of the dataset for non-commercial research and educational purposes.
172
+ In exchange, we request only that you make available to us the results of running your segmentation or
173
+ boundary detection algorithm on the test set as described below. Work based on the dataset should cite
174
+ the [Martin et al. (2001)](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=937655) paper.
175
+
176
+ ### Citation Information
177
+
178
+ ```bibtex
179
+ @inproceedings{martin2001database,
180
+ title={A database of human segmented natural images and its application to evaluating segmentation algorithms and measuring ecological statistics},
181
+ author={Martin, David and Fowlkes, Charless and Tal, Doron and Malik, Jitendra},
182
+ booktitle={Proceedings Eighth IEEE International Conference on Computer Vision. ICCV 2001},
183
+ volume={2},
184
+ pages={416--423},
185
+ year={2001},
186
+ organization={IEEE}
187
+ }
188
+ ```
189
+
190
+ ### Contributions
191
+
192
+ Thanks to [@eugenesiow](https://github.com/eugenesiow) for adding this dataset.
data/BSD100_HR.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:333495ccded04a0db52b33361140821ea7e0d8af8dfb54b58df79a00010858d6
3
+ size 27186832
data/BSD100_LR_x2.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6da0054efcf335dcf2da9e37105aad87a6e0778c0cf601f5f0d82b5e86e2569c
3
+ size 7336320
data/BSD100_LR_x3.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d344aab7f0167a408345632aae545bbae59a26a3048a8352e50352a23962ac64
3
+ size 3374269
data/BSD100_LR_x4.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71e47b5326dd6d66486a56900f3b61defc7874cf54a2c36d165d5ada1abcbbea
3
+ size 1925876