IOInstanceSegmentorConfig¶

class IOInstanceSegmentorConfig(input_resolutions, patch_input_shape, stride_shape=None, output_resolutions=<factory>, patch_output_shape=None, save_resolution=None, tile_shape=None, margin=None)[source]¶

Contains instance segmentor input and output information.

Parameters:
  • input_resolutions (list(dict)) – Resolution of each input head of model inference, must be in the same order as target model.forward().

  • patch_input_shape (numpy.ndarray, list(int), tuple(int, int)) – Shape of the largest input in (height, width).

  • stride_shape (numpy.ndarray, list(int), tuple(int, int)) – Stride in (x, y) direction for patch extraction.

  • output_resolutions (list(dict)) – Resolution of each output head from model inference, must be in the same order as target model.infer_batch().

  • patch_output_shape (numpy.ndarray, list(int)) – Shape of the largest output in (height, width).

  • save_resolution (dict) – Resolution to save all output.

  • margin (int) – Tile margin to accumulate the output.

  • tile_shape (tuple(int, int)) – Tile shape to process the WSI.

input_resolutions¶

Resolution of each input head of model inference, must be in the same order as target model.forward().

Type:

list(dict)

patch_input_shape¶

Shape of the largest input in (height, width).

Type:

numpy.ndarray, list(int), tuple(int, int)

stride_shape¶

Stride in (x, y) direction for patch extraction.

Type:

numpy.ndarray, list(int), tuple(int)

output_resolutions¶

Resolution of each output head from model inference, must be in the same order as target model.infer_batch().

Type:

list(dict)

patch_output_shape¶

Shape of the largest output in (height, width).

Type:

numpy.ndarray, list(int)

save_resolution¶

Resolution to save all output.

Type:

dict

highest_input_resolution¶

Highest resolution to process the image based on input and output resolutions. This helps to read the image at the optimal resolution and improves performance.

Type:

dict

margin¶

Tile margin to accumulate the output.

Type:

int

tile_shape¶

Tile shape to process the WSI.

Type:

tuple(int, int)

Examples

>>> # Defining io for a network having 1 input and 1 output at the
>>> # same resolution
>>> ioconfig = IOInstanceSegmentorConfig(
...     input_resolutions=[{"units": "baseline", "resolution": 1.0}],
...     output_resolutions=[{"units": "baseline", "resolution": 1.0}],
...     patch_input_shape=(2048, 2048),
...     patch_output_shape=(1024, 1024),
...     stride_shape=(512, 512),
...     margin=128,
...     tile_shape=(1024, 1024),
... )
>>> # Defining io for a network having 3 input and 2 output
>>> # at the same resolution, the output is then merged at a
>>> # different resolution.
>>> ioconfig = IOInstanceSegmentorConfig(
...     input_resolutions=[
...         {"units": "mpp", "resolution": 0.25},
...         {"units": "mpp", "resolution": 0.50},
...         {"units": "mpp", "resolution": 0.75},
...     ],
...     output_resolutions=[
...         {"units": "mpp", "resolution": 0.25},
...         {"units": "mpp", "resolution": 0.50},
...     ],
...     patch_input_shape=(2048, 2048),
...     patch_output_shape=(1024, 1024),
...     stride_shape=(512, 512),
...     save_resolution={"units": "mpp", "resolution": 4.0},
...     margin=128,
...     tile_shape=(1024, 1024),
... )

Methods

to_baseline

Returns a new config object converted to baseline form.

Attributes

to_baseline()[source]¶

Returns a new config object converted to baseline form.

This will return a new IOSegmentorConfig where resolutions have been converted to baseline format with the highest possible resolution found in both input and output as reference.

Parameters:

self (IOInstanceSegmentorConfig)

Return type:

IOInstanceSegmentorConfig