add dataset
Browse files- EuroSAT.py +201 -0
- README.md +35 -0
EuroSAT.py
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""EuroSAT dataset"""
|
16 |
+
|
17 |
+
|
18 |
+
import csv
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
_CITATION = """\
|
25 |
+
@article{helber2019eurosat,
|
26 |
+
title={Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification},
|
27 |
+
author={Helber, Patrick and Bischke, Benjamin and Dengel, Andreas and Borth, Damian},
|
28 |
+
journal={IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing},
|
29 |
+
year={2019},
|
30 |
+
publisher={IEEE}
|
31 |
+
}
|
32 |
+
"""
|
33 |
+
|
34 |
+
# TODO: Add description of the dataset here
|
35 |
+
# You can copy an official description
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
**Homepage:** https://github.com/phelber/EuroSAT
|
38 |
+
|
39 |
+
**IMPORTANT NOTES**
|
40 |
+
- This HF dataset downloads the RGB images of the EuroSAT dataset: https://zenodo.org/record/7711810#.ZAm3k-zMKEA; i.e., the EuroSAT_RGB.zip
|
41 |
+
"""
|
42 |
+
|
43 |
+
# TODO: Add a link to an official homepage for the dataset here
|
44 |
+
_HOMEPAGE = "https://github.com/phelber/EuroSAT"
|
45 |
+
|
46 |
+
# TODO: Add the licence for the dataset here if you can find it
|
47 |
+
_LICENSE = """MIT License
|
48 |
+
|
49 |
+
Copyright (c) 2023 Patrick Helber
|
50 |
+
|
51 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
52 |
+
of this software and associated documentation files (the "Software"), to deal
|
53 |
+
in the Software without restriction, including without limitation the rights
|
54 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
55 |
+
copies of the Software, and to permit persons to whom the Software is
|
56 |
+
furnished to do so, subject to the following conditions:
|
57 |
+
|
58 |
+
The above copyright notice and this permission notice shall be included in all
|
59 |
+
copies or substantial portions of the Software.
|
60 |
+
|
61 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
62 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
63 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
64 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
65 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
66 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
67 |
+
SOFTWARE.
|
68 |
+
"""
|
69 |
+
|
70 |
+
# TODO: Add link to the official dataset URLs here
|
71 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
72 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
73 |
+
# _URLS = {
|
74 |
+
# # "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
75 |
+
# # "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
76 |
+
# }
|
77 |
+
|
78 |
+
_URLS = {
|
79 |
+
"data": "https://zenodo.org/record/7711810/files/EuroSAT_RGB.zip",
|
80 |
+
}
|
81 |
+
|
82 |
+
def _load_EuroSAT_rgb(unzipped_dir):
|
83 |
+
data = []
|
84 |
+
for class_label in os.listdir(unzipped_dir):
|
85 |
+
# print(class_label)
|
86 |
+
class_dir = os.path.join(unzipped_dir, class_label)
|
87 |
+
for img_id in os.listdir(class_dir):
|
88 |
+
data.append(
|
89 |
+
{
|
90 |
+
"image_id":img_id,
|
91 |
+
"image_path":os.path.join(class_dir, img_id),
|
92 |
+
"class":class_label,
|
93 |
+
}
|
94 |
+
)
|
95 |
+
return data
|
96 |
+
|
97 |
+
|
98 |
+
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
99 |
+
class EuroSAT(datasets.GeneratorBasedBuilder):
|
100 |
+
"""TODO: Short description of my dataset."""
|
101 |
+
|
102 |
+
VERSION = datasets.Version("1.0.0")
|
103 |
+
|
104 |
+
# This is an example of a dataset with multiple configurations.
|
105 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
106 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
107 |
+
|
108 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
109 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
110 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
111 |
+
|
112 |
+
# You will be able to load one or the other configurations in the following list with
|
113 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
114 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
115 |
+
# BUILDER_CONFIGS = [
|
116 |
+
# datasets.BuilderConfig(name="first_domain", version=VERSION, description="This part of my dataset covers a first domain"),
|
117 |
+
# datasets.BuilderConfig(name="second_domain", version=VERSION, description="This part of my dataset covers a second domain"),
|
118 |
+
# ]
|
119 |
+
|
120 |
+
# DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
121 |
+
|
122 |
+
def _info(self):
|
123 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
124 |
+
# if self.config.name == "first_domain": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
125 |
+
# features = datasets.Features(
|
126 |
+
# {
|
127 |
+
# "sentence": datasets.Value("string"),
|
128 |
+
# "option1": datasets.Value("string"),
|
129 |
+
# "answer": datasets.Value("string")
|
130 |
+
# # These are the features of your dataset like images, labels ...
|
131 |
+
# }
|
132 |
+
# )
|
133 |
+
# else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
134 |
+
# features = datasets.Features(
|
135 |
+
# {
|
136 |
+
# "sentence": datasets.Value("string"),
|
137 |
+
# "option2": datasets.Value("string"),
|
138 |
+
# "second_domain_answer": datasets.Value("string")
|
139 |
+
# # These are the features of your dataset like images, labels ...
|
140 |
+
# }
|
141 |
+
# )
|
142 |
+
|
143 |
+
features = datasets.Features(
|
144 |
+
{
|
145 |
+
"image_id": datasets.Value("string"),
|
146 |
+
"image_path": datasets.Value("string"),
|
147 |
+
"class": datasets.Value("string"),
|
148 |
+
}
|
149 |
+
)
|
150 |
+
|
151 |
+
return datasets.DatasetInfo(
|
152 |
+
# This is the description that will appear on the datasets page.
|
153 |
+
description=_DESCRIPTION,
|
154 |
+
# This defines the different columns of the dataset and their types
|
155 |
+
features=features, # Here we define them above because they are different between the two configurations
|
156 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
157 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
158 |
+
# supervised_keys=("sentence", "label"),
|
159 |
+
# Homepage of the dataset for documentation
|
160 |
+
homepage=_HOMEPAGE,
|
161 |
+
# License for the dataset if available
|
162 |
+
license=_LICENSE,
|
163 |
+
# Citation for the dataset
|
164 |
+
citation=_CITATION,
|
165 |
+
)
|
166 |
+
|
167 |
+
def _split_generators(self, dl_manager):
|
168 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
169 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
170 |
+
|
171 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
172 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
173 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
174 |
+
|
175 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
176 |
+
|
177 |
+
print("downloaded_files: ", downloaded_files)
|
178 |
+
return [
|
179 |
+
datasets.SplitGenerator(
|
180 |
+
name=datasets.Split.TRAIN,
|
181 |
+
# These kwargs will be passed to _generate_examples
|
182 |
+
gen_kwargs={
|
183 |
+
"filepath": downloaded_files["data"],
|
184 |
+
"split": "train",
|
185 |
+
},
|
186 |
+
)
|
187 |
+
]
|
188 |
+
|
189 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
190 |
+
def _generate_examples(self, filepath, split):
|
191 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
192 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
193 |
+
|
194 |
+
data = _load_EuroSAT_rgb(filepath)
|
195 |
+
|
196 |
+
for key, row in enumerate(data):
|
197 |
+
yield key, {
|
198 |
+
"image_id": row["image_id"],
|
199 |
+
"image_path": row["image_path"],
|
200 |
+
"class": row["class"],
|
201 |
+
}
|
README.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1 |
---
|
|
|
|
|
|
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
pretty_name: 'EuroSAT (RGB)'
|
3 |
+
language:
|
4 |
+
- en
|
5 |
license: mit
|
6 |
---
|
7 |
+
# Dataset Card for EuroSAT Dataset (RGB)
|
8 |
+
|
9 |
+
## Dataset Description
|
10 |
+
|
11 |
+
**Homepage:** https://github.com/phelber/EuroSAT
|
12 |
+
|
13 |
+
**IMPORTANT NOTES**
|
14 |
+
- This HF dataset downloads the RGB images of the EuroSAT dataset: https://zenodo.org/record/7711810#.ZAm3k-zMKEA; i.e., the EuroSAT_RGB.zip
|
15 |
+
|
16 |
+
**Paper Citation:**
|
17 |
+
```
|
18 |
+
@article{helber2019eurosat,
|
19 |
+
title={Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification},
|
20 |
+
author={Helber, Patrick and Bischke, Benjamin and Dengel, Andreas and Borth, Damian},
|
21 |
+
journal={IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing},
|
22 |
+
year={2019},
|
23 |
+
publisher={IEEE}
|
24 |
+
}
|
25 |
+
```
|
26 |
+
```
|
27 |
+
@inproceedings{helber2018introducing,
|
28 |
+
title={Introducing EuroSAT: A Novel Dataset and Deep Learning Benchmark for Land Use and Land Cover Classification},
|
29 |
+
author={Helber, Patrick and Bischke, Benjamin and Dengel, Andreas and Borth, Damian},
|
30 |
+
booktitle={IGARSS 2018-2018 IEEE International Geoscience and Remote Sensing Symposium},
|
31 |
+
pages={204--207},
|
32 |
+
year={2018},
|
33 |
+
organization={IEEE}
|
34 |
+
}
|
35 |
+
```
|
36 |
+
|
37 |
+
## Dataset Summary
|
38 |
+
In this study, we address the challenge of land use and land cover classification using Sentinel-2 satellite images. The Sentinel-2 satellite images are openly and freely accessible provided in the Earth observation program Copernicus. We present a novel dataset based on Sentinel-2 satellite images covering 13 spectral bands and consisting out of 10 classes with in total 27,000 labeled and geo-referenced images. We provide benchmarks for this novel dataset with its spectral bands using state-of-the-art deep Convolutional Neural Network (CNNs). With the proposed novel dataset, we achieved an overall classification accuracy of 98.57%. The resulting classification system opens a gate towards a number of Earth observation applications. We demonstrate how this classification system can be used for detecting land use and land cover changes and how it can assist in improving geographical maps. The geo-referenced dataset EuroSAT is made publicly available [here](https://github.com/phelber/EuroSAT).
|