Datasets:

Modalities:
Geospatial
Languages:
English
DOI:
Libraries:
License:
cmalbrec commited on
Commit
bb665d0
·
verified ·
1 Parent(s): 7dae591

minor update of citation

Browse files
Files changed (1) hide show
  1. ssl4eo_eu_forest.py +116 -116
ssl4eo_eu_forest.py CHANGED
@@ -1,116 +1,116 @@
1
-
2
- import json
3
- import datasets
4
- from datasets.utils.file_utils import xopen
5
-
6
- class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
7
- """
8
- Metadata generator for the SSL4EO-EU-Forest dataset, cf. https://huggingface.co/datasets/dm4eo/ssl4eo_eu_forest .
9
- """
10
- def _info(self):
11
- """
12
- Provides details on metadata structure, citation, and credits.
13
- """
14
- return datasets.DatasetInfo(
15
- description="SSL4EO-EU Forest dataset metadata",
16
- features=datasets.Features({
17
- # data sample ID
18
- "group_id": datasets.Value("string"),
19
- # relative path (without HuggingFace URL) of forest mask
20
- "mask_path": datasets.Value("string"),
21
- # got bounding box in lat-lon coords
22
- "bbox_epsg4326": datasets.Sequence(datasets.Value("float32")),
23
- # image dimensions in width and height
24
- "mask_width": datasets.Value("int32"),
25
- "mask_height": datasets.Value("int32"),
26
- # do the above dimensions match for all the images?
27
- "dimensions_match": datasets.Value("bool"),
28
- # 12-band Sentinel-2 L2A cloud-free images for all seasons in bounding box
29
- "images": datasets.Sequence({
30
- # relative path (without HuggingFace URL) of Sentinel-2 imagery
31
- "path": datasets.Value("string"),
32
- # start time for data recording
33
- "timestamp_start": datasets.Value("string"),
34
- # end time for data recording
35
- "timestamp_end": datasets.Value("string"),
36
- # Sentinel-2 tile ID
37
- "tile_id": datasets.Value("string"),
38
- # season in northern hemisphere
39
- "season": datasets.Value("string"),
40
- # image dimensions
41
- "width": datasets.Value("int32"),
42
- "height": datasets.Value("int32")
43
- })
44
- }),
45
- # which keys refer to (input, output) data for supervised
46
- supervised_keys=("images", "mask_path"),
47
- # BibTeX on how to cite this work
48
- citation="""@misc{ssl4eo_eu_forest,
49
- author = {Nassim Ait Ali Braham and Conrad M Albrecht},
50
- title = {SSL4EO-EU Forest Dataset},
51
- year = {2025},
52
- howpublished = {https://huggingface.co/datasets/dm4eo/ssl4eo-eu-forest},
53
- 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.}
54
- }""",
55
- # project homepage
56
- homepage="https://www.evo-land.eu",
57
- # data license
58
- license="CC-BY-4.0",
59
- )
60
-
61
- def _split_generators(self, dl_manager):
62
- """
63
- Define dataset splits - single "training" split for now.
64
- """
65
- url = f"{dl_manager._base_path}/meta.jsonl"
66
- return [
67
- datasets.SplitGenerator(
68
- name=datasets.Split.TRAIN,
69
- gen_kwargs={"url": url},
70
- )
71
- ]
72
-
73
- def _generate_examples(self, url):
74
- """
75
- Streaming-compliant serving of metadata for SSL4EO data samples.
76
- """
77
- with xopen(url, encoding="utf-8") as f:
78
- for idx, line in enumerate(f):
79
- yield idx, json.loads(line)
80
-
81
-
82
- def features_to_croissant(features):
83
- """
84
- Convert a HF dataset feature into a Croissant-compatible description.
85
- """
86
- def convert_feature(name:str, feature:datasets.features.features.Features):
87
- if isinstance(feature, datasets.Value):
88
- return {
89
- "name": name,
90
- "dataType": feature.dtype,
91
- "description": f"{name} field"
92
- }
93
- elif isinstance(feature, datasets.Sequence):
94
- inner = feature.feature
95
- if isinstance(inner, dict): # nested structure
96
- return {
97
- "name": name,
98
- "isArray": True,
99
- "description": f"{name} sequence",
100
- "features": [convert_feature(k, v) for k, v in inner.items()]
101
- }
102
- elif isinstance(inner, Value): # flat sequence
103
- return {
104
- "name": name,
105
- "isArray": True,
106
- "description": f"{name} sequence",
107
- "dataType": inner.dtype
108
- }
109
- else:
110
- return {
111
- "name": name,
112
- "dataType": "unknown",
113
- "description": f"{name} field"
114
- }
115
-
116
- return [convert_feature(name, feature) for name, feature in features.items()]
 
1
+
2
+ import json
3
+ import datasets
4
+ from datasets.utils.file_utils import xopen
5
+
6
+ class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
7
+ """
8
+ Metadata generator for the SSL4EO-EU-Forest dataset, cf. https://huggingface.co/datasets/dm4eo/ssl4eo_eu_forest .
9
+ """
10
+ def _info(self):
11
+ """
12
+ Provides details on metadata structure, citation, and credits.
13
+ """
14
+ return datasets.DatasetInfo(
15
+ description="SSL4EO-EU Forest dataset metadata",
16
+ features=datasets.Features({
17
+ # data sample ID
18
+ "group_id": datasets.Value("string"),
19
+ # relative path (without HuggingFace URL) of forest mask
20
+ "mask_path": datasets.Value("string"),
21
+ # got bounding box in lat-lon coords
22
+ "bbox_epsg4326": datasets.Sequence(datasets.Value("float32")),
23
+ # image dimensions in width and height
24
+ "mask_width": datasets.Value("int32"),
25
+ "mask_height": datasets.Value("int32"),
26
+ # do the above dimensions match for all the images?
27
+ "dimensions_match": datasets.Value("bool"),
28
+ # 12-band Sentinel-2 L2A cloud-free images for all seasons in bounding box
29
+ "images": datasets.Sequence({
30
+ # relative path (without HuggingFace URL) of Sentinel-2 imagery
31
+ "path": datasets.Value("string"),
32
+ # start time for data recording
33
+ "timestamp_start": datasets.Value("string"),
34
+ # end time for data recording
35
+ "timestamp_end": datasets.Value("string"),
36
+ # Sentinel-2 tile ID
37
+ "tile_id": datasets.Value("string"),
38
+ # season in northern hemisphere
39
+ "season": datasets.Value("string"),
40
+ # image dimensions
41
+ "width": datasets.Value("int32"),
42
+ "height": datasets.Value("int32")
43
+ })
44
+ }),
45
+ # which keys refer to (input, output) data for supervised
46
+ supervised_keys=("images", "mask_path"),
47
+ # BibTeX on how to cite this work
48
+ citation="""@misc{ssl4eo_eu_forest,
49
+ author = {Ait Ali Braham, Nassim and Albrecht, Conrad M},
50
+ title = {SSL4EO-EU Forest Dataset},
51
+ year = {2025},
52
+ howpublished = {https://github.com/cmalbrec/ssl4eo_eu_forest},
53
+ 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.}
54
+ }""",
55
+ # project homepage
56
+ homepage="https://www.evo-land.eu",
57
+ # data license
58
+ license="CC-BY-4.0",
59
+ )
60
+
61
+ def _split_generators(self, dl_manager):
62
+ """
63
+ Define dataset splits - single "training" split for now.
64
+ """
65
+ url = f"{dl_manager._base_path}/meta.jsonl"
66
+ return [
67
+ datasets.SplitGenerator(
68
+ name=datasets.Split.TRAIN,
69
+ gen_kwargs={"url": url},
70
+ )
71
+ ]
72
+
73
+ def _generate_examples(self, url):
74
+ """
75
+ Streaming-compliant serving of metadata for SSL4EO data samples.
76
+ """
77
+ with xopen(url, encoding="utf-8") as f:
78
+ for idx, line in enumerate(f):
79
+ yield idx, json.loads(line)
80
+
81
+
82
+ def features_to_croissant(features):
83
+ """
84
+ Convert a HF dataset feature into a Croissant-compatible description.
85
+ """
86
+ def convert_feature(name:str, feature:datasets.features.features.Features):
87
+ if isinstance(feature, datasets.Value):
88
+ return {
89
+ "name": name,
90
+ "dataType": feature.dtype,
91
+ "description": f"{name} field"
92
+ }
93
+ elif isinstance(feature, datasets.Sequence):
94
+ inner = feature.feature
95
+ if isinstance(inner, dict): # nested structure
96
+ return {
97
+ "name": name,
98
+ "isArray": True,
99
+ "description": f"{name} sequence",
100
+ "features": [convert_feature(k, v) for k, v in inner.items()]
101
+ }
102
+ elif isinstance(inner, Value): # flat sequence
103
+ return {
104
+ "name": name,
105
+ "isArray": True,
106
+ "description": f"{name} sequence",
107
+ "dataType": inner.dtype
108
+ }
109
+ else:
110
+ return {
111
+ "name": name,
112
+ "dataType": "unknown",
113
+ "description": f"{name} field"
114
+ }
115
+
116
+ return [convert_feature(name, feature) for name, feature in features.items()]