Replies: 1 comment
-
duplicate of feature request #5135, a simple workaround would be using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
I found a wired bug in transforms. The following code is:
+++++++++++++++++++++++++++++++++++++++++++++
OneOf(transforms=[
Resized(keys=["image"],spatial_size=self.spatial_size),
Compose([
CenterSpatialCropd(keys=["image"], roi_size=self.spatial_size),
Resized(keys=["image"], spatial_size=self.spatial_size),
]),
Compose([
RandSpatialCropSamplesd(
keys=["image"],
roi_size=self.spatial_size,
num_samples=2,
random_center=True,
random_size=False,
),
Resized(keys=["image"], spatial_size=self.spatial_size),
]),
],
weights=[0, 0, 1]),
++++++++++++++++++++++++++++++++++++++++++++++++++
when we select one transform in OneOf combinations, such as weights = [0.4, 0.3, 0.3], we get the error output:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
File "Path/python3.11/site-packages/torch/utils/data/_utils/fetch.py", line 54, in fetch
return self.collate_fn(data)
^^^^^^^^^^^^^^^^^^^^^
File "Path/python3.11/site-packages/monai/data/utils.py", line 670, in pad_list_data_collate
return PadListDataCollate(method=method, mode=mode, **kwargs)(batch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Path/python3.11/site-packages/monai/transforms/croppad/batch.py", line 86, in call
if not isinstance(elem[key_or_idx], (torch.Tensor, np.ndarray)):
~~~~^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
++++++++++++++++++++++++++++++++++++++++++++++++++++++
when we select any transform combination in OneOf without RandSpatialCropSamplesd, such as weights=[0.5, 0.5, 0], the all is fine.
I think the problem is that RandSpatialCropSamplesd return a list data, [{}, {}], but other transforms return a dict {}. The pad_list_data_collate can not process handle list and dict interleaved data.
However, How to solve this problem cleverly? I really want to implement a combination of these transforms.
Beta Was this translation helpful? Give feedback.
All reactions