Utils

Sliding window inference

sliding_window_inference(inputs, roi_size, sw_batch_size, predictor, device)[source]

Use SlidingWindow method to execute inference.

Parameters
  • inputs (numpy array) – input image to be processed (assuming NCHW[D])

  • roi_size (list, tuple) – the window size to execute SlidingWindow inference.

  • sw_batch_size (int) – the batch size to run window slices.

  • predictor (Callable) – given input tensor patch_data in shape NCHW[D], predictor(patch_data) should return a prediction with the same spatial shape and batch_size, i.e. NMHW[D]; where HW[D] represents the patch spatial size, M is the number of output channels, N is sw_batch_size.

  • device – on which device to execute model inference, cpu or gpu.

Note

must be channel first, support both 2D and 3D. input data must have batch dim. execute on 1 image/per inference, run a batch of window slices of 1 input image.

Module utils

Aliases