Skip to content

Commit 9355f1c

Browse files
committed
WIP: debugging
1 parent 580645d commit 9355f1c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

monai/networks/layers/simplelayers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,11 @@ def median_filter(
499499
# map the local window to single vector
500500
conv = [F.conv1d, F.conv2d, F.conv3d][spatial_dims - 1] # type: ignore
501501
# even-sized kernels are not supported
502-
padding = [(k - 1) // 2 for k in kernel.shape[2:]]
503-
padded_input: torch.Tensor = F.pad(in_tensor.reshape(oprod, 1, *sshape), pad=padding, mode="replicate")
504-
features: torch.Tensor = conv(padded_input, kernel, stride=1, **kwargs) # type: ignore
502+
padding = [(k - 1) // 2 for k in kernel.shape[2:] for _ in range(2)]
503+
padded_input: torch.Tensor = F.pad(in_tensor, pad=padding, mode="replicate")
504+
psshape = padded_input.shape[-spatial_dims:]
505+
reshaped_input = padded_input.reshape(oprod, 1, *psshape)
506+
features: torch.Tensor = conv(reshaped_input, kernel, padding=0, stride=1, **kwargs) # type: ignore
505507
features = features.view(oprod, -1, *sshape) # type: ignore
506508

507509
# compute the median along the feature axis

0 commit comments

Comments
 (0)