Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions tiatoolbox/models/engine/engine_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,11 @@ def get_dataloader(
@staticmethod
def _update_model_output(raw_predictions: dict, raw_output: dict) -> dict:
"""Helper function to append raw output during inference."""
for key in raw_output:
for key, value in raw_output.items():
if raw_predictions[key] is None:
raw_predictions[key] = raw_output[key]
raw_predictions[key] = value
else:
raw_predictions[key] = np.append(
raw_predictions[key], raw_output[key], axis=0
)
raw_predictions[key] = np.append(raw_predictions[key], value, axis=0)

return raw_predictions

Expand Down
11 changes: 5 additions & 6 deletions tiatoolbox/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,20 +1490,19 @@ def write_to_zarr_in_cache_mode(

# case 1 - new zarr group
if not zarr_group:
for key in output_data_to_save:
data_to_save = output_data_to_save[key]
for key, value in output_data_to_save.items():
# populate the zarr group for the first time
zarr_dataset = zarr_group.create_dataset(
name=key,
shape=data_to_save.shape,
shape=value.shape,
compressor=compressor,
)
zarr_dataset[:] = data_to_save
zarr_dataset[:] = value

return zarr_group

# case 2 - append to existing zarr group
for key in output_data_to_save:
zarr_group[key].append(output_data_to_save[key])
for key, value in output_data_to_save.items():
zarr_group[key].append(value)

return zarr_group