Medical-SAM-Adapter
Medical-SAM-Adapter copied to clipboard
Error in validation, Shape mismatch, can't divide axis of length X in chunks of Y
Although there is no issue in training, but in validation stage I always get this type of error for BTCV dataset, on default processing:
Traceback (most recent call last): File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/hm4013/.conda/envs/mul2/lib/python3.9/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/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/io/dictionary.py", line 164, in call data = self._loader(d[key], reader) File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/io/array.py", line 302, in call img = EnsureChannelFirst()(img) File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/utility/array.py", line 204, in call raise ValueError(msg) ValueError: Metadata not available and channel_dim=None, EnsureChannelFirst is not in use.
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/hm4013/.conda/envs/mul2/lib/python3.9/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/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/compose.py", line 322, in call result = execute_compose( File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/transforms/compose.py", line 111, in execute_compose data = apply_transform( File "/home/hm4013/.conda/envs/mul2/lib/python3.9/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 0x7feb3cdd5d90>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/monai/data/thread_buffer.py", line 49, in enqueue_values
for src_val in self.src:
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 630, in next
data = self._next_data()
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 673, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 52, in
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/einops/einops.py", line 523, in reduce
return _apply_recipe(
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/einops/einops.py", line 234, in _apply_recipe
init_shapes, axes_reordering, reduced_axes, added_axes, final_shapes, n_axes_w_added = _reconstruct_from_shape(
File "/home/hm4013/.conda/envs/mul2/lib/python3.9/site-packages/einops/einops.py", line 187, in _reconstruct_from_shape_uncached
raise EinopsError(f"Shape mismatch, can't divide axis of length {length} in chunks of {known_product}")
einops.EinopsError: Shape mismatch, can't divide axis of length 311 in chunks of 96
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hm4013/Medical-SAM-Adapter/val.py", line 102, in