Skip to content

Commit ec3e5d9

Browse files
committed
update decollate item
1 parent 68a27e1 commit ec3e5d9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

monai/data/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ def decollate_batch(batch, detach: bool = True, pad=True, fill_value=None):
625625
type(batch).__module__ == "numpy" and not isinstance(batch, Iterable)
626626
):
627627
return batch
628-
if isinstance(batch, np.ndarray) and batch.ndim == 0:
629-
batch = torch.from_numpy(batch)
628+
if getattr(batch, "ndim", -1) == 0 and hasattr(batch, "item"):
629+
return batch.item() if detach else batch
630630
if isinstance(batch, torch.Tensor):
631631
if detach:
632632
batch = batch.detach()

0 commit comments

Comments
 (0)