ValueError: Sequence must have length 2, got 3. #5642
Unanswered
Frankieljy
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi @Frankieljy, could you please share your code, seems you specify |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Traceback (most recent call last):
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/transforms/transform.py", line 90, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/transforms/transform.py", line 54, in _apply_transform
return transform(parameters)
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/transforms/croppad/dictionary.py", line 678, in call
box_start, box_end = self.cropper.compute_bounding_box(img=d[self.source_key])
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/transforms/croppad/array.py", line 840, in compute_bounding_box
spatial_size = np.asarray(compute_divisible_spatial_size(orig_spatial_size.tolist(), k=self.k_divisible))
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/transforms/utils.py", line 1300, in compute_divisible_spatial_size
k = fall_back_tuple(k, (1,) * len(spatial_shape))
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/utils/misc.py", line 197, in fall_back_tuple
user = ensure_tuple_rep(user_provided, ndim)
File "/home/ljy0808/anaconda3/envs/monai/lib/python3.7/site-packages/monai/utils/misc.py", line 154, in ensure_tuple_rep
raise ValueError(f"Sequence must have length {dim}, got {len(tup)}.")
ValueError: Sequence must have length 2, got 3.
I debug this and find:
spatial_size = img.shape[1:]
data = img[list(ensure_tuple(channel_indices))] if channel_indices is not None else img
data = select_fn(data).any(0)
ndim = len(data.shape)
margin = ensure_tuple_rep(margin, ndim)
generate_spatial_bounding_box create the ndim which is the shape of data and this problem also find in:generate_spatial_bounding_box looses first dimension #3723
and i try to delete any(0),but make a lot of problems
Beta Was this translation helpful? Give feedback.
All reactions