Datasets:
Upload 2 files
Browse filesupdate HF dataset definition files
- dataset.py +40 -19
- dataset_info.json +1 -1
dataset.py
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
import datasets
|
| 3 |
import rasterio
|
| 4 |
import tqdm
|
|
|
|
| 5 |
|
| 6 |
class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
|
| 7 |
def _info(self):
|
| 8 |
return datasets.DatasetInfo(
|
| 9 |
-
description="SSL4EO-EU Forest dataset with four-season
|
| 10 |
features=datasets.Features({
|
| 11 |
-
"
|
| 12 |
"mask_path": datasets.Value("string"),
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
"minx": datasets.Value("float32"),
|
| 18 |
"maxx": datasets.Value("float32"),
|
| 19 |
"miny": datasets.Value("float32"),
|
| 20 |
"maxy": datasets.Value("float32"),
|
| 21 |
-
}
|
| 22 |
}),
|
| 23 |
citation="""@misc{ssl4eo_eu_forest,
|
| 24 |
author = {Nassim Ait Ali Braham and Conrad M Albrecht},
|
|
@@ -53,7 +55,7 @@ class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
|
|
| 53 |
sample_id_list = sorted(os.listdir(images_dir))
|
| 54 |
key = 0
|
| 55 |
|
| 56 |
-
for sample_id in
|
| 57 |
sample_path = os.path.join(images_dir, sample_id)
|
| 58 |
if not os.path.isdir(sample_path):
|
| 59 |
continue
|
|
@@ -63,12 +65,24 @@ class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
|
|
| 63 |
if not os.path.exists(mask_path):
|
| 64 |
continue
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
for ts in timestamp_dirs:
|
| 67 |
parts = ts.split("_")
|
| 68 |
if len(parts) != 3:
|
| 69 |
continue
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
image_path = os.path.join(sample_path, ts, "all_bands.tif")
|
| 73 |
if not os.path.exists(image_path):
|
| 74 |
continue
|
|
@@ -79,17 +93,24 @@ class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
|
|
| 79 |
except Exception:
|
| 80 |
continue
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
yield key, {
|
| 83 |
-
"
|
| 84 |
"mask_path": mask_path,
|
| 85 |
-
"
|
| 86 |
-
"
|
| 87 |
-
"
|
| 88 |
-
"
|
| 89 |
-
"minx": bounds.left,
|
| 90 |
-
"maxx": bounds.right,
|
| 91 |
-
"miny": bounds.bottom,
|
| 92 |
-
"maxy": bounds.top
|
| 93 |
-
}
|
| 94 |
}
|
| 95 |
key += 1
|
|
|
|
| 1 |
+
|
| 2 |
import os
|
| 3 |
import datasets
|
| 4 |
import rasterio
|
| 5 |
import tqdm
|
| 6 |
+
import datetime
|
| 7 |
|
| 8 |
class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
|
| 9 |
def _info(self):
|
| 10 |
return datasets.DatasetInfo(
|
| 11 |
+
description="SSL4EO-EU Forest dataset with four-season Sentinel-2 timestamps and bounding box metadata extracted from image folders.",
|
| 12 |
features=datasets.Features({
|
| 13 |
+
"image_paths": datasets.Sequence(datasets.Value("string")),
|
| 14 |
"mask_path": datasets.Value("string"),
|
| 15 |
+
"start_timestamps": datasets.Sequence(datasets.Value("timestamp[ms]")),
|
| 16 |
+
"end_timestamps": datasets.Sequence(datasets.Value("timestamp[ms]")),
|
| 17 |
+
"sentinel_tile_ids": datasets.Sequence(datasets.Value("string")),
|
| 18 |
+
"bboxes": datasets.Sequence({
|
| 19 |
"minx": datasets.Value("float32"),
|
| 20 |
"maxx": datasets.Value("float32"),
|
| 21 |
"miny": datasets.Value("float32"),
|
| 22 |
"maxy": datasets.Value("float32"),
|
| 23 |
+
})
|
| 24 |
}),
|
| 25 |
citation="""@misc{ssl4eo_eu_forest,
|
| 26 |
author = {Nassim Ait Ali Braham and Conrad M Albrecht},
|
|
|
|
| 55 |
sample_id_list = sorted(os.listdir(images_dir))
|
| 56 |
key = 0
|
| 57 |
|
| 58 |
+
for sample_id in sample_id_list:
|
| 59 |
sample_path = os.path.join(images_dir, sample_id)
|
| 60 |
if not os.path.isdir(sample_path):
|
| 61 |
continue
|
|
|
|
| 65 |
if not os.path.exists(mask_path):
|
| 66 |
continue
|
| 67 |
|
| 68 |
+
image_paths = []
|
| 69 |
+
start_timestamps = []
|
| 70 |
+
end_timestamps = []
|
| 71 |
+
tile_ids = []
|
| 72 |
+
bboxes = []
|
| 73 |
+
|
| 74 |
for ts in timestamp_dirs:
|
| 75 |
parts = ts.split("_")
|
| 76 |
if len(parts) != 3:
|
| 77 |
continue
|
| 78 |
|
| 79 |
+
try:
|
| 80 |
+
start_ts = datetime.datetime.strptime(parts[0], "%Y%m%dT%H%M%S")
|
| 81 |
+
end_ts = datetime.datetime.strptime(parts[1], "%Y%m%dT%H%M%S")
|
| 82 |
+
except ValueError:
|
| 83 |
+
continue
|
| 84 |
+
|
| 85 |
+
tile_id = parts[2]
|
| 86 |
image_path = os.path.join(sample_path, ts, "all_bands.tif")
|
| 87 |
if not os.path.exists(image_path):
|
| 88 |
continue
|
|
|
|
| 93 |
except Exception:
|
| 94 |
continue
|
| 95 |
|
| 96 |
+
image_paths.append(image_path)
|
| 97 |
+
start_timestamps.append(start_ts)
|
| 98 |
+
end_timestamps.append(end_ts)
|
| 99 |
+
tile_ids.append(tile_id)
|
| 100 |
+
bboxes.append({
|
| 101 |
+
"minx": bounds.left,
|
| 102 |
+
"maxx": bounds.right,
|
| 103 |
+
"miny": bounds.bottom,
|
| 104 |
+
"maxy": bounds.top
|
| 105 |
+
})
|
| 106 |
+
|
| 107 |
+
if image_paths:
|
| 108 |
yield key, {
|
| 109 |
+
"image_paths": image_paths,
|
| 110 |
"mask_path": mask_path,
|
| 111 |
+
"start_timestamps": start_timestamps,
|
| 112 |
+
"end_timestamps": end_timestamps,
|
| 113 |
+
"sentinel_tile_ids": tile_ids,
|
| 114 |
+
"bboxes": bboxes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
key += 1
|
dataset_info.json
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"description": "SSL4EO-EU Forest dataset with four-season
|
|
|
|
| 1 |
+
{"description": "SSL4EO-EU Forest dataset with four-season Sentinel-2 timestamps and bounding box metadata extracted from image folders.", "citation": "@misc{ssl4eo_eu_forest,\n author = {Nassim Ait Ali Braham and Conrad M Albrecht},\n title = {SSL4EO-EU Forest Dataset},\n year = {2025},\n howpublished = {https://huggingface.co/datasets/dm4eo/ssl4eo-eu-forest},\n note = {This work was carried under the EvoLand project, cf. https://www.evo-land.eu . This project has received funding from the European Union's Horizon Europe research and innovation programme under grant agreement No. 101082130.}\n}", "homepage": "https://www.evo-land.eu", "license": "CC-BY-4.0", "features": {"image_paths": {"feature": {"dtype": "string", "_type": "Value"}, "_type": "Sequence"}, "mask_path": {"dtype": "string", "_type": "Value"}, "start_timestamps": {"feature": {"dtype": "timestamp[ms]", "_type": "Value"}, "_type": "Sequence"}, "end_timestamps": {"feature": {"dtype": "timestamp[ms]", "_type": "Value"}, "_type": "Sequence"}, "sentinel_tile_ids": {"feature": {"dtype": "string", "_type": "Value"}, "_type": "Sequence"}, "bboxes": {"feature": {"minx": {"dtype": "float32", "_type": "Value"}, "maxx": {"dtype": "float32", "_type": "Value"}, "miny": {"dtype": "float32", "_type": "Value"}, "maxy": {"dtype": "float32", "_type": "Value"}}, "_type": "Sequence"}}}
|