Skip to content

Image Write Strategy

Source

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.

__init__(write_func, write_extension, write_func_kwargs)

A strategy for writing image predictions (i.e. un-tiled predictions).

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.

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.