Rhodes
commited on
Commit
•
d02e724
1
Parent(s):
b2d9e8c
:new: Added support for ChaBud test
Browse files
california_burned_areas.py
CHANGED
@@ -39,7 +39,7 @@ _HOMEPAGE = "https://huggingface.co/datasets/DarthReca/california_burned_areas"
|
|
39 |
|
40 |
_LICENSE = "OPENRAIL"
|
41 |
|
42 |
-
_URLS = "raw/patched/512x512.hdf5"
|
43 |
|
44 |
|
45 |
class CaBuArConfig(datasets.BuilderConfig):
|
@@ -68,7 +68,7 @@ class CaBuArConfig(datasets.BuilderConfig):
|
|
68 |
class CaBuAr(datasets.GeneratorBasedBuilder):
|
69 |
"""California Burned Areas dataset."""
|
70 |
|
71 |
-
VERSION = datasets.Version("1.
|
72 |
|
73 |
BUILDER_CONFIGS = [
|
74 |
CaBuArConfig(
|
@@ -119,26 +119,27 @@ class CaBuAr(datasets.GeneratorBasedBuilder):
|
|
119 |
)
|
120 |
|
121 |
def _split_generators(self, dl_manager):
|
122 |
-
|
123 |
|
124 |
return [
|
125 |
datasets.SplitGenerator(
|
126 |
-
name=fold,
|
127 |
# These kwargs will be passed to _generate_examples
|
128 |
gen_kwargs={
|
129 |
"fold": fold,
|
130 |
"load_prefire": self.config.load_prefire,
|
131 |
-
"filepath":
|
132 |
},
|
133 |
)
|
134 |
-
for fold in range(0, 5)
|
135 |
]
|
136 |
|
137 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
138 |
def _generate_examples(self, fold: int, load_prefire: bool, filepath):
|
|
|
139 |
with h5py.File(filepath, "r") as f:
|
140 |
for uuid, values in f.items():
|
141 |
-
if values.attrs["fold"] != fold:
|
142 |
continue
|
143 |
if load_prefire and "pre_fire" not in values:
|
144 |
continue
|
|
|
39 |
|
40 |
_LICENSE = "OPENRAIL"
|
41 |
|
42 |
+
_URLS = ["raw/patched/512x512.hdf5", "raw/patched/chabud_test.h5"]
|
43 |
|
44 |
|
45 |
class CaBuArConfig(datasets.BuilderConfig):
|
|
|
68 |
class CaBuAr(datasets.GeneratorBasedBuilder):
|
69 |
"""California Burned Areas dataset."""
|
70 |
|
71 |
+
VERSION = datasets.Version("1.1.0")
|
72 |
|
73 |
BUILDER_CONFIGS = [
|
74 |
CaBuArConfig(
|
|
|
119 |
)
|
120 |
|
121 |
def _split_generators(self, dl_manager):
|
122 |
+
h5_files = dl_manager.download(_URLS)
|
123 |
|
124 |
return [
|
125 |
datasets.SplitGenerator(
|
126 |
+
name=fold if fold != 5 else "chabud_test",
|
127 |
# These kwargs will be passed to _generate_examples
|
128 |
gen_kwargs={
|
129 |
"fold": fold,
|
130 |
"load_prefire": self.config.load_prefire,
|
131 |
+
"filepath": h5_files[file_index],
|
132 |
},
|
133 |
)
|
134 |
+
for fold, file_index in zip(range(0, 6), [0] * 5 + [1])
|
135 |
]
|
136 |
|
137 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
138 |
def _generate_examples(self, fold: int, load_prefire: bool, filepath):
|
139 |
+
print(f"Loading fold {fold} from {filepath}")
|
140 |
with h5py.File(filepath, "r") as f:
|
141 |
for uuid, values in f.items():
|
142 |
+
if fold != 5 and values.attrs["fold"] != fold:
|
143 |
continue
|
144 |
if load_prefire and "pre_fire" not in values:
|
145 |
continue
|