Replies: 3 comments 9 replies
-
Hi @laizhui, from the error message, seems you specified wrong type of Lines 274 to 275 in 8212458 Hope it helps, thanks! |
Beta Was this translation helpful? Give feedback.
6 replies
-
ValueError: Sequence must have length 2, got 3. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello, I have the same problem as you. How did you solve it? Is there a problem with the dataset or some other reason? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I try to train a SwinUNETR model on my own MRI dataset, using the code and model.pt file given at:
https://githubfast.com/Project-MONAI/research-contributions/tree/main/SwinUNETR/BRATS21
However, I got errors as follows:
`Traceback (most recent call last):
File "main.py", line 229, in
main()
File "main.py", line 104, in main
main_worker(gpu=0, args=args)
File "main.py", line 210, in main_worker
accuracy = run_training(
File "/home/zwlai/BRATS21/trainer.py", line 157, in run_training
train_loss = train_epoch(
File "/home/zwlai/BRATS21/trainer.py", line 32, in train_epoch
for idx, batch_data in enumerate(loader):
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/opt/Anaconda/lib/python3.8/site-packages/torch/_utils.py", line 434, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 89, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 53, in _apply_transform
return transform(parameters)
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/croppad/dictionary.py", line 889, in call
box_start, box_end = self.cropper.compute_bounding_box(img=d[self.source_key])
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/croppad/array.py", line 744, in compute_bounding_box
spatial_size = np.asarray(compute_divisible_spatial_size(orig_spatial_size.tolist(), k=self.k_divisible))
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/utils.py", line 1293, in compute_divisible_spatial_size
k = fall_back_tuple(k, (1,) * len(spatial_shape))
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/utils/misc.py", line 189, in fall_back_tuple
user = ensure_tuple_rep(user_provided, ndim)
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/utils/misc.py", line 146, in ensure_tuple_rep
raise ValueError(f"Sequence must have length {dim}, got {len(tup)}.")
ValueError: Sequence must have length 2, got 3.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 89, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 53, in apply_transform
return transform(parameters)
File "/home/zwlai/.local/lib/python3.8/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/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 113, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.croppad.dictionary.CropForegroundd object at 0x7f79d6a06130>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/Anaconda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/data/dataset.py", line 97, in getitem
return self._transform(index)
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/data/dataset.py", line 83, in _transform
return apply_transform(self.transform, data_i) if self.transform is not None else data_i
File "/home/zwlai/.local/lib/python3.8/site-packages/monai/transforms/transform.py", line 113, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x7f79d6a71a30>`
How should I fix this error?
And I want to change output labels from 3 to 5, what should I do?
Any comments would be highly appreciated.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions