Skip to content

Commit c438fe0

Browse files
committed
support decollate for numpy scalars
fix linter Signed-off-by: Arthur Dujardin <[email protected]> fix numpy decollate multi arrays Signed-off-by: Arthur Dujardin <[email protected]> fix linter Signed-off-by: Arthur Dujardin <[email protected]> fix numpy scalar support Signed-off-by: Arthur Dujardin <[email protected]> minor refactoring for typing Signed-off-by: Arthur Dujardin <[email protected]>
1 parent c3a317d commit c438fe0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

monai/data/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +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+
return batch.item() if detach else batch
628630
if isinstance(batch, torch.Tensor):
629631
if detach:
630632
batch = batch.detach()

0 commit comments

Comments
 (0)