IOSegmentorConfig¶
- class IOSegmentorConfig(input_resolutions, output_resolutions, patch_input_shape, patch_output_shape, save_resolution=None, **kwargs)[source]¶
Contain semantic segmentor input and output information.
- Parameters:
input_resolutions (list) – Resolution of each input head of model inference, must be in the same order as target model.forward().
output_resolutions (list) – Resolution of each output head from model inference, must be in the same order as target model.infer_batch().
patch_input_shape (
numpy.ndarray
, list(int)) – Shape of the largest input in (height, width).patch_output_shape (
numpy.ndarray
, list(int)) – Shape of the largest output in (height, width).save_resolution (dict) – Resolution to save all output.
kwargs (dict)
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], ... )
Examples
>>> # 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}, ... )
Initialize
IOSegmentorConfig
.Methods
Get the scaling factor from input resolutions.
Return a new config object converted to baseline form.
Attributes
input_resolutions
output_resolutions
- static scale_to_highest(resolutions, units)[source]¶
Get the scaling factor from input resolutions.
This will convert resolutions to a scaling factor with respect to the highest resolution found in the input resolutions list.
- Parameters:
resolutions (list) – A list of resolutions where one is defined as {‘resolution’: value, ‘unit’: value}
units (Units) – Units that the resolutions are at.
- Returns:
A 1D array of scaling factors having the same length as resolutions
- Return type:
- to_baseline()[source]¶
Return 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 (IOSegmentorConfig)
- Return type: