Making sense of inference times using sliding_window_inference
function
#7021
-
Hello MONAI team! Thank you very much for maintaining this wonderful package. I have been playing with I am using the following preprocessing transforms, where def inference_transforms(crop_size, lbl_key="label"):
return Compose([
LoadImaged(keys=["image", lbl_key], image_only=False),
EnsureChannelFirstd(keys=["image", lbl_key]),
Orientationd(keys=["image", lbl_key], axcodes="RPI"),
Spacingd(keys=["image", lbl_key], pixdim=(1.0, 1.0, 1.0), mode=(2, 1)),
ResizeWithPadOrCropd(keys=["image", lbl_key], spatial_size=crop_size,),
DivisiblePadd(keys=["image", lbl_key], k=2**5),
NormalizeIntensityd(keys=["image"], nonzero=False, channel_wise=False),
]) I am calling the sliding window function like this:
I have a dataset of 294 images and my
I am unable to understand how decreasing the overlap by half is increasing the inference time. If I understand correctly, having less overlap between patches should ultimately decrease the number of sliding windows, hence reduce the inference time? And as per this comment, I increased Am I missing anything else that might be going on under the Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @naga-karthik, runtime does vary a bit on the CPU, maybe you could try inference on the GPU. |
Beta Was this translation helpful? Give feedback.
Hi @naga-karthik, there are many factors that influence CPU test times so I said that it may be better benchmarked on GPU.
You are correct in your understanding that reducing the overlap should ideally decrease the number of sliding windows, potentially reducing inference time. However, in practice, the behavior can be more complex. The overlap affects the number of windows and their positions but can also impact the efficiency of processing each window. Increasing the
sw_batch_size
should allow for more parallel processing, which could lead to faster inference times. However, this might not always be the case, and the effectiveness of this change can be influenced by factors like CPU arc…