Skip to content

Commit c84099b

Browse files
authored
Merge branch 'dev-define-engines-abc' into dev-define-semantic-segmentor
2 parents 333264a + e93d98a commit c84099b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

tiatoolbox/models/engine/engine_abc.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,11 @@ def get_dataloader(
505505
@staticmethod
506506
def _update_model_output(raw_predictions: dict, raw_output: dict) -> dict:
507507
"""Helper function to append raw output during inference."""
508-
for key in raw_output:
508+
for key, value in raw_output.items():
509509
if raw_predictions[key] is None:
510-
raw_predictions[key] = raw_output[key]
510+
raw_predictions[key] = value
511511
else:
512-
raw_predictions[key] = np.append(
513-
raw_predictions[key], raw_output[key], axis=0
514-
)
512+
raw_predictions[key] = np.append(raw_predictions[key], value, axis=0)
515513

516514
return raw_predictions
517515

tiatoolbox/utils/misc.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,20 +1490,19 @@ def write_to_zarr_in_cache_mode(
14901490

14911491
# case 1 - new zarr group
14921492
if not zarr_group:
1493-
for key in output_data_to_save:
1494-
data_to_save = output_data_to_save[key]
1493+
for key, value in output_data_to_save.items():
14951494
# populate the zarr group for the first time
14961495
zarr_dataset = zarr_group.create_dataset(
14971496
name=key,
1498-
shape=data_to_save.shape,
1497+
shape=value.shape,
14991498
compressor=compressor,
15001499
)
1501-
zarr_dataset[:] = data_to_save
1500+
zarr_dataset[:] = value
15021501

15031502
return zarr_group
15041503

15051504
# case 2 - append to existing zarr group
1506-
for key in output_data_to_save:
1507-
zarr_group[key].append(output_data_to_save[key])
1505+
for key, value in output_data_to_save.items():
1506+
zarr_group[key].append(value)
15081507

15091508
return zarr_group

0 commit comments

Comments
 (0)