From e8e1440162ed94a7514e28521d95043313597154 Mon Sep 17 00:00:00 2001 From: Thomas Kierski <54414492+ThomasKierski@users.noreply.github.com> Date: Sat, 26 Oct 2024 04:46:28 -0400 Subject: [PATCH] BUG: Fix traceback in restored transform (#1766) Using transforms from MONAI and MONAILabel can result in metadata containing torch.tensors and torch.Sizes. This change fixes a traceback in the restored transform resulting from an incompatibility between torch datatypes and numpy.any(). Signed-off-by: Thomas Kierski --- monailabel/transform/post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monailabel/transform/post.py b/monailabel/transform/post.py index cf4abdf96..615040474 100644 --- a/monailabel/transform/post.py +++ b/monailabel/transform/post.py @@ -129,7 +129,7 @@ def __call__(self, data): spatial_size = spatial_shape[-len(current_size) :] # Undo Spacing - if np.any(np.not_equal(current_size, spatial_size)): + if torch.any(torch.Tensor(np.not_equal(current_size, spatial_size))): resizer = Resize(spatial_size=spatial_size, mode=self.mode[idx]) result = resizer(result, mode=self.mode[idx], align_corners=self.align_corners[idx])