Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix traceback in restored transform #1766

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: Fix traceback in restored transform
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 <thomas.kierski@revvity.com>
  • Loading branch information
ThomasKierski committed Oct 25, 2024
commit b6bf5e8fb76b60ac67f39a0b17f4a9bd4dccc5f4
2 changes: 1 addition & 1 deletion monailabel/transform/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down