Skip to content

Commit f1f2771

Browse files
author
Emma Ai
committed
combine dask ops
1 parent a9bdd82 commit f1f2771

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ odc-dscache>=0.2.3
1111
odc-stac @ git+https://github.com/opendatacube/odc-stac@69bdf64
1212

1313
# odc-stac is in PyPI
14-
odc-stats[ows] @ git+https://github.com/opendatacube/odc-stats@d7307d9
14+
odc-stats[ows] @ git+https://github.com/opendatacube/odc-stats@a9bdd82
1515

1616
# For ML
1717
tflite-runtime

odc/stats/plugins/lc_treelite_cultivated.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ def generate_features(input_block, bands_indices):
227227
return output_block
228228

229229

230+
def cultivated_predict(input_block, bands_indices):
231+
feature_block = generate_features(input_block, bands_indices)
232+
cc = mask_and_predict(feature_block, ptype="categorical", nodata=NODATA)
233+
return cc
234+
235+
230236
class StatsCultivatedClass(StatsMLTree):
231237
NAME = "ga_ls_cultivated"
232238
SHORT_NAME = NAME
@@ -240,23 +246,10 @@ def measurements(self) -> Tuple[str, ...]:
240246

241247
def predict(self, input_array):
242248
bands_indices = dict(zip(self.input_bands, np.arange(len(self.input_bands))))
243-
input_features = da.map_blocks(
244-
generate_features,
249+
cc = da.map_blocks(
250+
cultivated_predict,
245251
input_array,
246252
bands_indices,
247-
chunks=(
248-
input_array.chunks[0],
249-
input_array.chunks[1],
250-
15 + len(bands_indices) - bands_indices["bcdev"] - 1,
251-
),
252-
dtype="float32",
253-
name="generate_features",
254-
)
255-
cc = da.map_blocks(
256-
mask_and_predict,
257-
input_features,
258-
ptype="categorical",
259-
nodata=NODATA,
260253
drop_axis=-1,
261254
dtype="float32",
262255
name="cultivated_predict",

0 commit comments

Comments
 (0)