Auto3DSeg transforms TypeError: \'list\' object is not callable
See original GitHub issueDescribe the bug Hi,
I am trying to run Auto3DSeg on a custom dataset, but get the following error: TypeError: \'list\' object is not callable
which is caused by RuntimeError: applying transform [<monai.transforms.intensity.dictionary.ScaleIntensityRanged object at 0x7f46227911f0>, <monai.transforms.croppad.dictionary.CropForegroundd object at 0x7f46227912b0>]
. I will paste the full stack trace under Additional Context.
I was looking at segresnet_0/configs/transforms_train.yaml
and found it weird that ScaleIntensityRanged
and CropForegroundd
are two subitems:
_meta_: {}
image_key: image
label_key: label
transforms_train:
_target_: Compose
transforms:
- _target_: LoadImaged
keys: ['@image_key', '@label_key']
- _target_: EnsureChannelFirstd
keys: ['@image_key', '@label_key']
- _target_: Orientationd
axcodes: RAS
keys: ['@image_key', '@label_key']
- _target_: EnsureTyped
data_type: tensor
keys: ['@image_key', '@label_key']
- _target_: Spacingd
align_corners: [true, true]
keys: ['@image_key', '@label_key']
mode: [bilinear, nearest]
pixdim: [1.0, 1.0, 1.0]
- - {_target_: ScaleIntensityRanged, a_max: 463.44656227730417, a_min: -182.44375897098232,
b_max: 1.0, b_min: 0.0, clip: true, keys: '@image_key'}
- _target_: CropForegroundd
keys: ['@image_key', '@label_key']
source_key: '@image_key'
- _target_: SpatialPadd
keys: ['@image_key', '@label_key']
mode: [constant, constant]
spatial_size: '@patch_size'
...
Maybe this is causing the problem?
Environment
================================
Printing MONAI config...
================================ MONAI version: 1.0.0 Numpy version: 1.23.3 Pytorch version: 1.12.1+cu113
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 170093375ce29267e45681fcec09dfa856e1d7e7
MONAI __file__: /home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/__init__.py
Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 4.0.2
scikit-image version: 0.19.3
Pillow version: 9.2.0
Tensorboard version: 2.10.1
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: NOT INSTALLED or UNKNOWN VERSION.
tqdm version: 4.64.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: 5.9.2
pandas version: 1.5.0 einops version: 0.4.1
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...
================================
System: Linux
Linux version: Ubuntu 20.04.4 LTS
Platform: Linux-5.15.0-43-generic-x86_64-with-glibc2.31
Processor: x86_64
Machine: x86_64
Python version: 3.9.13
Process name: python
Command: ['/home/user/Code/psma-seg/.venv/bin/python', '-c', 'import monai; monai.config.print_debug_info()'] Open files: []
Num physical CPUs: 64
Num logical CPUs: 128
Num usable CPUs: 128
CPU usage (%): [2.1, 9.7, 9.7, 9.7, 10.8, 10.9, 9.8, 10.6, 10.8, 10.6, 7.4, 9.8, 9.8, 10.9, 6.3, 1.1, 10.6, 10.6, 10.8, 10.6, 9.8, 10.6, 9.8, 8.7, 9.8, 10.6, 9.7, 10.6, 9.7, 9.8, 10.8, 9.7, 9.8, 9.8, 9.7, 9.8, 10.8, 8.8, 9.8, 9.8, 10.6, 9.8, 9.7, 10.6, 9.7, 10.8, 9.8, 9.7, 9.7, 0.0, 0.0, 10.8, 0.0, 0.0, 0.0, 9.7, 9.7, 9.7, 9.8, 9.7, 0.0, 9.7, 0.0, 38.3, 9.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.2, 0.0, 0.0, 0.0, 5.4, 8.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.8, 9.8, 0.0, 9.8, 10.6, 9.8, 0.0, 0.0, 0.0, 0.0, 0.0, 9.8, 0.0, 9.8, 60.2]
CPU freq. (MHz): 2212
Load avg. in last 1, 5, 15 mins (%): [0.1, 0.1, 0.0]
Disk usage (%): 81.7
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 251.6
Available memory (GB): 238.5
Used memory (GB): 10.9
================================
Printing GPU config...
================================
Num GPUs: 4
Has CUDA: True
CUDA version: 11.3
cuDNN enabled: True cuDNN version: 8302
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 GeForce RTX 3090 GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 82
GPU 0 Total memory (GB): 23.7
GPU 0 CUDA capability (maj.min): 8.6
GPU 1 Name: NVIDIA GeForce RTX 3090
GPU 1 Is integrated: False
GPU 1 Is multi GPU board: False
GPU 1 Multi processor count: 82
GPU 1 Total memory (GB): 23.7
GPU 1 CUDA capability (maj.min): 8.6
GPU 2 Name: NVIDIA GeForce RTX 3090
GPU 2 Is integrated: False
GPU 2 Is multi GPU board: False
GPU 2 Multi processor count: 82
GPU 2 Total memory (GB): 23.7 GPU 2 CUDA capability (maj.min): 8.6
GPU 3 Name: NVIDIA GeForce RTX 3090
GPU 3 Is integrated: False
GPU 3 Is multi GPU board: False
GPU 3 Multi processor count: 82 GPU 3 Total memory (GB): 23.7 GPU 3 CUDA capability (maj.min): 8.6
Additional context
Full traceback:
Add any other context about the problem here.
Traceback (most recent call last): [273/1454] File "/home/user/Code/psma-seg/psma_seg/train_auto3dseg.py", line 48, in <module> main() File "/home/user/Code/psma-seg/psma_seg/train_auto3dseg.py", line 13, in main fire.Fire(train) File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/home/user/Code/psma-seg/psma_seg/train_auto3dseg.py", line 44, in train runner.run()
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/apps/auto3dseg/auto_runner.py", line 586, in run
self._train_algo_in_sequence(history)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/apps/auto3dseg/auto_runner.py", line 488, in _train_algo_in_sequence
algo.train(self.train_params)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/apps/auto3dseg/bundle_gen.py", line 200, in train
return self._run_cmd(cmd, devices_info)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/apps/auto3dseg/bundle_gen.py", line 188, in _run_cmd
raise RuntimeError(f"subprocess call error {e.returncode}: {errors}, {output}") from e RuntimeError: subprocess call error 1: b'Traceback (most recent call last): File "/home/user/Data/auto3dseg/psma-seg-LMU-CT/segresnet_0/scripts/train.py", line 405, in <module> fire.Fire()
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire component, remaining_args = _CallAndUpdateTrace(
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, **kwargs)
File "/home/user/Data/auto3dseg/psma-seg-LMU-CT/segresnet_0/scripts/train.py", line 234, in run for batch_data in train_loader:
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 681, in __next__
data = self._next_data()
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
return self._process_data(data)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
data.reraise()
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/_utils.py", line 461, in reraise raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 91, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 55, in _apply_transform
return transform(parameters)
TypeError: \'list\' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 91, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 55, in _apply_transform
return transform(parameters)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/compose.py", line 173, in __call__
input_ = apply_transform(_transform, input_, self.map_items, self.unpack_items, self.log_stats) File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 118, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e RuntimeError: applying transform [<monai.transforms.intensity.dictionary.ScaleIntensityRanged object at 0x7f46227911f0>, <monai.transforms.croppad.dictionary.CropForegroundd object at 0x7f46227912b0>]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/data/dataset.py", line 105, in __getitem__ return self._transform(index)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/data/dataset.py", line 863, in _transform return super()._transform(index_)
File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/data/dataset.py", line 91, in _transform return apply_transform(self.transform, data_i) if self.transform is not None else data_i File "/home/user/Code/psma-seg/.venv/lib/python3.9/site-packages/monai/transforms/transform.py", line 118, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x7f4622791d30>
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
TypeError: 'list' object is not callable in python - Stack Overflow
Seems like you've shadowed the builtin name list , which points at a class, by the same name pointing at an instance of...
Read more >TypeError: 'list' object is not callable in Python - STechies
This tutorial explains how to resolve TypeError: 'list' object is not callable in Python with proper examples. To resolve this error, you need...
Read more >Transforms — MONAI 1.1.0 Documentation
TypeError – When keys type is not in Union[Hashable, Iterable[Hashable]] . ... transform to each item in the input data if data is...
Read more >TypeError: 'list' object is not callable - PyTorch Forums
pre_process is a plain list , while a transformation is expected. You could pass the list to transforms.Compose to make it callable.
Read more >Python typeerror: 'list' object is not callable Solution
On Career Karma, learn about the Python typeerror: 'list' object is not callable error, how the error works, and how to solve the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @chris-clem , I am unsure if you have already solved the problem. We have just updated the algorithm templates. I would expect these problems will go away after these changes
are applied through setting the exports before you run the tutorials.
If you still have any questions, please feel free to reopen the ticket. Thanks!
@KumoLiu Thanks for the identifying the problem swiftly. Can you submit a PR in research contribution?
@chris-clem Once we update the default templates and finish the test there, we will provide a hash tag and you can use the up-to-date template.