-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
questionFurther information is requestedFurther information is requested
Milestone
Description
Describe the bug
The Numpy loader creates the wrong spatial_shape metadata field.
To Reproduce
Use this code:
import numpy as np
from monai.transforms.io.dictionary import LoadImageD
from monai.transforms.utility.dictionary import ToTensorD
from monai.transforms.compose import Compose
from monai.data.dataset import Dataset
from monai.data.dataloader import DataLoader
data = [
{
"numpy": "/home/danieltudosiu/storage/tmp2/002_S_0295_ADNI1_M_84.90_1.5T_HC_45107_quantization_0.npy"
},
{
"numpy": "/home/danieltudosiu/storage/tmp2/002_S_0413_ADNI1_F_76.38_1.5T_HC_45116_quantization_0.npy"
},
{
"numpy": "/home/danieltudosiu/storage/tmp2/002_S_0559_ADNI1_M_79.37_1.5T_HC_40673_quantization_0.npy"
},
{
"numpy": "/home/danieltudosiu/storage/tmp2/002_S_0619_ADNI1_M_77.55_1.5T_AD_48616_quantization_0.npy"
},
{
"numpy": "/home/danieltudosiu/storage/tmp2/002_S_0685_ADNI1_F_89.67_1.5T_HC_40682_quantization_0.npy"
},
]
transforms = Compose(
[
LoadImageD(keys=["numpy"], reader="numpyreader", dtype=np.int32),
ToTensorD(keys=["numpy"]),
]
)
ds = Dataset(data=data, transform=transforms)
dl = DataLoader(dataset=ds, batch_size=5)
for d in dl:
print(d)
Expected behavior
The spatial_shape field should be a list of list each with 3 elements.
Something like:
[tensor([20,28,20]),tensor([20,28,20]),tensor([20,28,20]),tensor([20,28,20]),tensor([20,28,20])]
But instead we get:
[tensor([20, 20, 20, 20, 20]), tensor([28, 28, 28, 28, 28]), tensor([20, 20, 20, 20, 20])]
Environment
Ensuring you use the relevant python executable, please paste the output of:
================================
Printing MONAI config...
================================
MONAI version: 0.7.0
Numpy version: 1.21.3
Pytorch version: 1.10.0+cu102
MONAI flags: HAS_EXT = False, USE_COMPILED = False
MONAI rev id: bfa054b9c3064628a21f4c35bbe3132964e91f43
Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: NOT INSTALLED or UNKNOWN VERSION.
scikit-image version: NOT INSTALLED or UNKNOWN VERSION.
Pillow version: NOT INSTALLED or UNKNOWN VERSION.
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: NOT INSTALLED or UNKNOWN VERSION.
tqdm version: NOT INSTALLED or UNKNOWN VERSION.
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: NOT INSTALLED or UNKNOWN VERSION.
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: NOT INSTALLED or UNKNOWN VERSION.
transformers version: NOT INSTALLED or UNKNOWN VERSION.
For details about installing the optional dependencies, please visit:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies
================================
Printing system config...
================================
`psutil` required for `print_system_info`
================================
Printing GPU config...
================================
Num GPUs: 2
Has CUDA: True
CUDA version: 10.2
cuDNN enabled: True
cuDNN version: 7605
Current device: 0
Library compiled for CUDA architectures: ['sm_37', 'sm_50', 'sm_60', 'sm_70']
GPU 0 Name: TITAN V
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 80
GPU 0 Total memory (GB): 11.8
GPU 0 CUDA capability (maj.min): 7.0
GPU 1 Name: GeForce GT 1030
GPU 1 Is integrated: False
GPU 1 Is multi GPU board: False
GPU 1 Multi processor count: 3
GPU 1 Total memory (GB): 2.0
GPU 1 CUDA capability (maj.min): 6.1
Additional context
This error has been lurking since 0.5.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested