From af9ba85f288c6e26a8d918085699633a076a0312 Mon Sep 17 00:00:00 2001 From: Fabian Isensee Date: Fri, 27 Oct 2023 13:52:00 +0200 Subject: [PATCH] set dtype in proper place to make use of blown up value range (and with is precision) in Gaussian --- nnunetv2/inference/sliding_window_prediction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nnunetv2/inference/sliding_window_prediction.py b/nnunetv2/inference/sliding_window_prediction.py index 07316cfa7..a6f8ebbae 100644 --- a/nnunetv2/inference/sliding_window_prediction.py +++ b/nnunetv2/inference/sliding_window_prediction.py @@ -17,10 +17,10 @@ def compute_gaussian(tile_size: Union[Tuple[int, ...], List[int]], sigma_scale: tmp[tuple(center_coords)] = 1 gaussian_importance_map = gaussian_filter(tmp, sigmas, 0, mode='constant', cval=0) - gaussian_importance_map = torch.from_numpy(gaussian_importance_map).type(dtype).to(device) + gaussian_importance_map = torch.from_numpy(gaussian_importance_map) gaussian_importance_map = gaussian_importance_map / torch.max(gaussian_importance_map) * value_scaling_factor - gaussian_importance_map = gaussian_importance_map.type(dtype) + gaussian_importance_map = gaussian_importance_map.type(dtype).to(device) # gaussian_importance_map cannot be 0, otherwise we may end up with nans! gaussian_importance_map[gaussian_importance_map == 0] = torch.min(