Tiler#

class model_api.tilers.tiler.Tiler(model, configuration={}, execution_mode='async')#

Bases: ABC, Generic[ResultT]

Base constructor for creating a tiling pipeline

Parameters:
  • model – underlying model

  • configuration (dict) – it contains values for parameters accepted by specific tiler (tile_size, tiles_overlap etc.) which are set as data attributes.

  • execution_mode (str) – Controls inference mode of the tiler (async or sync).

classmethod parameters()#

Defines the description and type of configurable data parameters for the tiler.

The structure is similar to model wrapper parameters.

Returns:

  • the dictionary with defined wrapper tiler parameters

__call__(inputs)#

Applies full pipeline of tiling inference in one call.

Parameters:

inputs – raw input data, the data type is defined by underlying model wrapper

Return type:

TypeVar(ResultT, bound= Result)

Returns:

  • postprocessed data in the format defined by underlying model wrapper

get_model()#

Getter for underlying model

predict_tiles(tiles, tile_coords, shape)#

Run tiled inference on externally provided (already cropped) tiles and merge.

This mirrors __call__() but skips the internal tiling stage (_tile / _filter_tiles / _crop_tile): the caller supplies the tile crops together with their absolute coordinates in the full image. This supports pipelines that perform tiling upstream (e.g. inside a data loader) while still reusing the tiler’s per-task _postprocess_tile and _merge_results logic.

The underlying model runs once per provided tile, so callers must not pass tiles through a model that itself tiles internally (that would tile each tile a second time).

Parameters:
  • tiles – sequence of pre-cropped tile images, each in the layout expected by the underlying model wrapper (typically (H, W, C) arrays).

  • tile_coords – sequence of [x1, y1, x2, y2] absolute tile coordinates in the full image, aligned with tiles.

  • shape – full-resolution image shape ((H, W, C) or (H, W)) used to place and merge the per-tile predictions.

Return type:

TypeVar(ResultT, bound= Result)

Returns:

Merged prediction in the format produced by _merge_results.

Raises:

ValueError – if tiles and tile_coords have different lengths.

EXECUTION_MODES = ('async', 'sync')#

An abstract tiler

The abstract tiler is free from any executor dependencies. It sets the Model instance with the provided model and applies it to tiles of the input image, and then merges results from all tiles.

The _postprocess_tile and _merge_results methods must be implemented in a specific inherited tiler. .. attribute:: logger

instance of the Logger

type:

Logger

model#

model being executed

Type:

Model

model_loaded#

a flag whether the model is loaded to device

Type:

bool

async_pipeline#

a pipeline for asynchronous execution mode

Type:

AsyncPipeline

execution_mode#

Controls inference mode of the tiler (async or sync).