Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

SaveImaged not working after upgrading MONAI from 0.8.1 to 1.0.1 #5801

Closed
moonforsun opened this issue Jan 3, 2023 · 1 comment
Closed

Comments

@moonforsun
Copy link

moonforsun commented Jan 3, 2023

Describe the bug
I upgraded the MONAI from 0.8.1 to 1.0.1.
Then my original yaml config as following that works on 0.8.1 does not work anymore on 1.0.1.

_target_: SaveImaged, keys: model_output_key, meta_keys: [ 'labels_meta_dict' ], data_root_dir: label_root_dir, output_dir: pred_output_dir, output_postfix: 'pred', separate_folder: False

Any help would be greatly appreciated!

Expected behavior
I expect the code to save the output to nii file.

Screenshots
Error trackback followed in the end.

Environment

Ensuring you use the relevant python executable, please paste the output of:

python -c 'import monai; monai.config.print_debug_info()'

================================
Printing MONAI config...

MONAI version: 1.0.1
Numpy version: 1.24.1
Pytorch version: 1.13.1+cu117
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 8271a19
MONAI file: /home/ubuntu/.cache/pypoetry/virtualenvs/qbio-qbdl-D8V9KvtL-py3.8/lib/python3.8/site-packages/monai/init.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 3.2.2
scikit-image version: 0.19.3
Pillow version: 9.4.0
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: 0.14.1+cu117
tqdm version: 4.64.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: NOT INSTALLED or UNKNOWN VERSION.
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.5.0
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd 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: 4
Has CUDA: True
CUDA version: 11.7
cuDNN enabled: True
cuDNN version: 8500
Current device: 0
Library compiled for CUDA architectures: ['sm_37', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86']
GPU 0 Name: NVIDIA A10G
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 80
GPU 0 Total memory (GB): 22.2
GPU 0 CUDA capability (maj.min): 8.6
GPU 1 Name: NVIDIA A10G
GPU 1 Is integrated: False
GPU 1 Is multi GPU board: False
GPU 1 Multi processor count: 80
GPU 1 Total memory (GB): 22.2
GPU 1 CUDA capability (maj.min): 8.6
GPU 2 Name: NVIDIA A10G
GPU 2 Is integrated: False
GPU 2 Is multi GPU board: False
GPU 2 Multi processor count: 80
GPU 2 Total memory (GB): 22.2
GPU 2 CUDA capability (maj.min): 8.6
GPU 3 Name: NVIDIA A10G
GPU 3 Is integrated: False
GPU 3 Is multi GPU board: False
GPU 3 Multi processor count: 80
GPU 3 Total memory (GB): 22.2
GPU 3 CUDA capability (maj.min): 8.6

Additional context
Add any other context about the problem here.
Error traceback:

Traceback (most recent call last):
File "/home/ubuntu/.cache/pypoetry/virtualenvs/qbio-qbdl-D8V9KvtL-py3.8/lib/python3.8/site-packages/monai/transforms/transform.py", line 91, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/ubuntu/.cache/pypoetry/virtualenvs/qbio-qbdl-D8V9KvtL-py3.8/lib/python3.8/site-packages/monai/transforms/transform.py", line 55, in _apply_transform
return transform(parameters)
File "/home/ubuntu/.cache/pypoetry/virtualenvs/qbio-qbdl-D8V9KvtL-py3.8/lib/python3.8/site-packages/monai/transforms/io/dictionary.py", line 293, in call
self.saver(img=d[key], meta_data=meta_data)
File "/home/ubuntu/.cache/pypoetry/virtualenvs/qbio-qbdl-D8V9KvtL-py3.8/lib/python3.8/site-packages/monai/transforms/io/array.py", line 423, in call
subject = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index)
KeyError: 'filename_or_obj'

@wyli
Copy link
Member

wyli commented Jan 4, 2023

perhaps remove any ToTensor transform in the preprocessing to preserve the metadata?

see also Project-MONAI/tutorials#881 and #4764

@Project-MONAI Project-MONAI locked and limited conversation to collaborators Jan 4, 2023
@wyli wyli converted this issue into discussion #5806 Jan 4, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants