Skip to content

Compositional Patch-based Inference #5837

@bhashemian

Description

@bhashemian

Currently, SlidingWindowInferer and SlidingWindowHoVerNetInferer rely on sliding_window_inferer, which lacks flexibility and structure to generalize to other use cases. For instance, different way of splitting image into patches (e.g., whole slide images or patch filtering), or different way of merging the result patches together.

To make the inference on patches more modular and extensible, I have prepared the following design and would appreciate your feedbacks on it.

In this way, similar behavior to SlidingWindowInferer:

SlidingWindowInferer(roi_shape=(256, 256), overlap=0.5, mode="gaussian", sigma_scale=1.0, sw_batch_size=8)

can be achieved as following:

PatchInference(splitter=SlidingPatchSplitter(patch_size=(256, 256), overlap=0.5), merger=GaussianMerger(sigma=1.0), batch_size=8)

while it is easy to extend this via composition of splitter and merger.

For instance, use the maximum value for overlapping regions:

PatchInference(splitter=SlidingPatchSplitter(patch_size=(256, 256), overlap=0.5), merger=MaxMerger())

or use a whole slide image as an input:

PatchInference(splitter=WSISlidingPatchSplitter(patch_size=(256, 256), overlap=0.5), merger=MaxMerger())

Here, I mentioned few concrete classes for Splitter and Merger as example but many more concrete classes can implemented to extend the usage of PatchInference.

PatchInference

PS: I would suggest to change the name of Inferer base class to Inference since "inferer" does not exist in English vocabulary.

CC: @Nic-Ma @ericspod @wyli @rijobro

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

💯 Complete

Relationships

None yet

Development

No branches or pull requests

Issue actions