otx.core.utils.tile_merge#

OTX tile merge module.

Classes

DetectionTileMerge(img_infos, num_classes, ...)

Detection tile merge.

InstanceSegTileMerge(img_infos, num_classes, ...)

Instance segmentation tile merge.

TileMerge(img_infos, num_classes, tile_config)

Base class for tile merge.

class otx.core.utils.tile_merge.DetectionTileMerge(img_infos: list[ImageInfo], num_classes: int, tile_config: TileConfig, explain_mode: bool = False)[source]#

Bases: TileMerge

Detection tile merge.

merge(batch_tile_preds: list[DetBatchPredEntity], batch_tile_attrs: list[list[dict]]) list[DetPredEntity][source]#

Merge batch tile predictions to a list of full-size prediction data entities.

Parameters:
  • batch_tile_preds (list) – detection tile predictions.

  • batch_tile_attrs (list) – detection tile attributes.

class otx.core.utils.tile_merge.InstanceSegTileMerge(img_infos: list[ImageInfo], num_classes: int, tile_config: TileConfig, explain_mode: bool = False)[source]#

Bases: TileMerge

Instance segmentation tile merge.

get_saliency_maps_from_masks(labels: Tensor, scores: Tensor, masks: None | Tensor, num_classes: int) ndarray[source]#

Average and normalize predicted masks in per-class.

Returns:

Class-wise Saliency Maps. One saliency map per each class - [class_id, H, W]

Return type:

np.array

merge(batch_tile_preds: list[InstanceSegBatchPredEntity], batch_tile_attrs: list[list[dict]]) list[InstanceSegPredEntity][source]#

Merge inst-seg tile predictions to one single prediction.

Parameters:
  • batch_tile_preds (list) – instance-seg tile predictions.

  • batch_tile_attrs (list) – instance-seg tile attributes.

class otx.core.utils.tile_merge.TileMerge(img_infos: list[ImageInfo], num_classes: int, tile_config: TileConfig, explain_mode: bool = False)[source]#

Bases: Generic[T_OTXDataEntity, T_OTXBatchPredEntity]

Base class for tile merge.

Parameters:
  • img_infos (list[ImageInfo]) – Original image information before tiling.

  • num_classes (int) – Number of classes.

  • tile_config (TileConfig) – Tile configuration.

  • explain_mode (bool, optional) – Whether or not tiles have explain features. Default: False.

abstract merge(batch_tile_preds: list[T_OTXBatchPredEntity], batch_tile_attrs: list[list[dict]]) list[T_OTXDataEntity][source]#

Merge batch tile predictions to a list of full-size prediction data entities.

Parameters:
  • batch_tile_preds (list) – list of tile predictions.

  • batch_tile_attrs (list) – list of tile attributes.

nms_postprocess(bboxes: Tensor, scores: Tensor, labels: Tensor, masks: None | list[Tensor] = None) tuple[Tensor, Tensor, Tensor, None | Tensor][source]#

Non-maximum suppression and post-process.