Datasets:
Create nesteo_prototype.py
Browse files- nesteo_prototype.py +52 -0
nesteo_prototype.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pyarrow.parquet as pq
|
3 |
+
import datasets
|
4 |
+
|
5 |
+
_CITATION = ""
|
6 |
+
_DESCRIPTION = "Wyvern dataset with encoded image arrays and masks per 2400m tile."
|
7 |
+
_HOMEPAGE = ""
|
8 |
+
_LICENSE = "cc-by-4.0"
|
9 |
+
|
10 |
+
class NestEOPrototype(datasets.GeneratorBasedBuilder):
|
11 |
+
VERSION = datasets.Version("1.0.0")
|
12 |
+
|
13 |
+
def _info(self):
|
14 |
+
return datasets.DatasetInfo(
|
15 |
+
description=_DESCRIPTION,
|
16 |
+
citation=_CITATION,
|
17 |
+
homepage=_HOMEPAGE,
|
18 |
+
license=_LICENSE,
|
19 |
+
features=datasets.Features({
|
20 |
+
"tile_id": datasets.Value("string"),
|
21 |
+
"scene_id": datasets.Value("string"),
|
22 |
+
"start_datetime": datasets.Value("timestamp[us]"),
|
23 |
+
"end_datetime": datasets.Value("timestamp[us]"),
|
24 |
+
"image": datasets.Value("binary"),
|
25 |
+
"data_mask": datasets.Value("binary"),
|
26 |
+
"pixel_quality_mask": datasets.Value("binary"),
|
27 |
+
"shape": [datasets.Value("int32")],
|
28 |
+
}),
|
29 |
+
)
|
30 |
+
|
31 |
+
def _split_generators(self, dl_manager):
|
32 |
+
wyvern_path = os.path.join(dl_manager.manual_dir, "datasets_EO/Wyvern/grid_2400m")
|
33 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"folder_path": wyvern_path})]
|
34 |
+
|
35 |
+
def _generate_examples(self, folder_path):
|
36 |
+
idx = 0
|
37 |
+
for fname in sorted(os.listdir(folder_path)):
|
38 |
+
if fname.endswith(".parquet"):
|
39 |
+
table = pq.read_table(os.path.join(folder_path, fname))
|
40 |
+
df = table.to_pandas()
|
41 |
+
for _, row in df.iterrows():
|
42 |
+
yield idx, {
|
43 |
+
"tile_id": row["tile_id"],
|
44 |
+
"scene_id": row["scene_id"],
|
45 |
+
"start_datetime": row["start_datetime"],
|
46 |
+
"end_datetime": row["end_datetime"],
|
47 |
+
"image": row["image"],
|
48 |
+
"data_mask": row["data_mask"],
|
49 |
+
"pixel_quality_mask": row["pixel_quality_mask"],
|
50 |
+
"shape": row["shape"],
|
51 |
+
}
|
52 |
+
idx += 1
|