IOSegmentorConfig¶
tiatoolbox.models.engine.io_config.IOSegmentorConfig
- class IOSegmentorConfig(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 semantic 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)) – 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.
tile_shape (tuple(int, int)) – Tile shape to process the WSI.
margin (int | None)
- input_resolutions¶
Resolution of each input head of model inference, must be in the same order as target model.forward().
- 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, int)
- output_resolutions¶
Resolution of each output head from model inference, must be in the same order as target model.infer_batch().
- patch_output_shape¶
Shape of the largest output in (height, width).
- Type:
numpy.ndarray, list(int)
- 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:
Examples
>>> # Defining io for a network having 1 input and 1 output at the >>> # same resolution >>> ioconfig = IOSegmentorConfig( ... 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), ... ) ... >>> # 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 = IOSegmentorConfig( ... 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}, ... )
Methods
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
IOSegmentorConfigwhere resolutions have been converted to baseline format with the highest possible resolution found in both input and output as reference.- Parameters:
self (IOSegmentorConfig)
- Return type: