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

RuntimeError: applying transform <monai.transforms.io.dictionary.LoadImaged object at 0x7f0f84fb8a90> #313

Open
SiruLiu645 opened this issue Oct 2, 2023 · 7 comments

Comments

@SiruLiu645
Copy link

截屏2023-10-02 20 32 32
could you please help me to save this problem?

@wyli
Copy link
Contributor

wyli commented Oct 2, 2023

That's been addressed earlier Project-MONAI/MONAI#5603 please upgrade monai or downgrade itk...

@ASCI02
Copy link

ASCI02 commented Mar 27, 2024

have you solved this problem?Can you tell me the solution

@DJ-CHB
Copy link

DJ-CHB commented Apr 8, 2024

I am having the same issue.. Did you find the solution?

@ASCI02
Copy link

ASCI02 commented Apr 8, 2024

I am having the same issue.. Did you find the solution?

Yes, you can fix this by reinstalling monai with "pip install 'monai[all]==1.1.0'"

@DJ-CHB
Copy link

DJ-CHB commented Apr 8, 2024

I am trying to run on the BRATS-21 dataset.

python3 main.py --json_list=./jsons/brats21_folds.json --data_dir=./BRATS-2021/ --max_epochs=300 --val_every=5 --noamp --distributed --roi_x=128 --roi_y=128 --roi_z=128 --in_channels=4 --spatial_dims=3 --use_checkpoint --feature_size=48 --fold=0

Original Traceback (most recent call last):
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform
    return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
    return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/io/dictionary.py", line 162, in __call__
    data = self._loader(d[key], reader)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/io/array.py", line 282, in __call__
    img_array, meta_data = reader.get_data(img)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/data/image_reader.py", line 938, in get_data
    data = self._get_array_data(i)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/data/image_reader.py", line 1012, in _get_array_data
    return np.asanyarray(img.dataobj, order="C")
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/nibabel/arrayproxy.py", line 391, in __array__
    arr = self._get_scaled(dtype=dtype, slicer=())
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/nibabel/arrayproxy.py", line 358, in _get_scaled
    scaled = apply_read_scaling(self._get_unscaled(slicer=slicer), scl_slope, scl_inter)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/nibabel/arrayproxy.py", line 332, in _get_unscaled
    return array_from_file(self._shape,
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/nibabel/volumeutils.py", line 523, in array_from_file
    n_read = infile.readinto(data_bytes)
  File "/soft/AIDL/conda_envs/pytorch-200/lib/python3.10/gzip.py", line 301, in read
    return self._buffer.read(size)
  File "/soft/AIDL/conda_envs/pytorch-200/lib/python3.10/_compression.py", line 68, in readinto
    data = self.read(len(byte_view))
  File "/soft/AIDL/conda_envs/pytorch-200/lib/python3.10/gzip.py", line 479, in read
    self._read_eof()
  File "/soft/AIDL/conda_envs/pytorch-200/lib/python3.10/gzip.py", line 525, in _read_eof
    raise BadGzipFile("CRC check failed %s != %s" % (hex(crc32),
gzip.BadGzipFile: CRC check failed 0xe9a51edc != 0x4190aef7

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform
    return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
    return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/compose.py", line 335, in __call__
    result = execute_compose(
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/compose.py", line 111, in execute_compose
    data = apply_transform(
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform
    raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.io.dictionary.LoadImaged object at 0x145fb63fbc40>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 58, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/data/dataset.py", line 112, in __getitem__
    return self._transform(index)
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/data/dataset.py", line 98, in _transform
    return apply_transform(self.transform, data_i) if self.transform is not None else data_i
  File "/home/2022022/djain02/packages/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform
    raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x145fb641c400>

I am getting this error even with monai 1.1.0 and 1.3.0

@one2clouds
Copy link

one2clouds commented Apr 22, 2024

As in my case it gave the suggestion to visit this website:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

As the error was due to monai not installing necessary libraries like ITK,etc... to load the images...
So, this does help:
pip install 'monai[all]==1.1.0'

@AbdulRehman0004
Copy link

It can resolved if you install numpy. version 1.21.6 with the monai version suggested in the requirement.txt
I am working on this with brats dataset but I am wondering why my dice score is too low..... can one able to regenerate the results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants