Image Write Strategy
A strategy writing whole images directly.
ImageWriteStrategy
Bases: WriteStrategy
A strategy for writing whole image predictions (i.e. un-tiled predictions).
Predictions are cached until all samples for a given data_idx are collected, then combined and written. This prevents overwrites when S_dim > batch_size.
Parameters:
-
write_func(WriteFunc) –Function used to save predictions.
-
write_extension(str) –Extension added to prediction file paths.
-
write_func_kwargs(dict of {str: Any}) –Extra kwargs to pass to
write_func.
Attributes:
-
write_func(WriteFunc) –Function used to save predictions.
-
write_extension(str) –Extension added to prediction file paths.
-
write_func_kwargs(dict of {str: Any}) –Extra kwargs to pass to
write_func. -
image_cache(dict of {int: list of ImageRegionData}) –Cache for predictions across batches, keyed by data_idx.
-
source_base(Path or None) –Common parent of the sources, used to preserve their directory structure. Set via
set_source_base.
__init__(write_func, write_extension, write_func_kwargs)
set_source_base(source_base)
Set the common parent directory of the sources.
Called by the prediction writer callback so that the directory structure of the sources can be preserved in the output.
Parameters:
-
source_base(Path or None) –Common parent of all prediction sources. If None, outputs are written directly under the output directory without preserving structure.
write_batch(dirpath, predictions)
Cache predictions and save full images.
Predictions are cached by data_idx until all samples (S dimension) are collected, then combined and written.
Parameters:
-
dirpath(Path) –Path to directory to save predictions to.
-
predictions(list[ImageRegionData]) –Decollated predictions.