TypeError: only integer scalar arrays can be converted to a scalar index #471
DieHumbleX
started this conversation in
General
Replies: 1 comment 7 replies
-
|
Code works on commenting tio.RandomFlip() |
Beta Was this translation helpful? Give feedback.
7 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to run this tutorial ( https://colab.research.google.com/github/fepegar/torchio-notebooks/blob/main/notebooks/TorchIO_tutorial.ipynb#scrollTo=zzVqpgRf5eFN )
i get following error:
TypeError Traceback (most recent call last) <ipython-input-25-5b4812ec9e10> in <module> ----> 1 one_batch = next(iter(training_loader)) /opt/conda/lib/python3.6/site-packages/torch/utils/data/dataloader.py in __next__(self) 433 if self._sampler_iter is None: 434 self._reset() --> 435 data = self._next_data() 436 self._num_yielded += 1 437 if self._dataset_kind == _DatasetKind.Iterable and \ /opt/conda/lib/python3.6/site-packages/torch/utils/data/dataloader.py in _next_data(self) 473 def _next_data(self): 474 index = self._next_index() # may raise StopIteration --> 475 data = self._dataset_fetcher.fetch(index) # may raise StopIteration 476 if self._pin_memory: 477 data = _utils.pin_memory.pin_memory(data) /opt/conda/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index) 42 def fetch(self, possibly_batched_index): 43 if self.auto_collation: ---> 44 data = [self.dataset[idx] for idx in possibly_batched_index] 45 else: 46 data = self.dataset[possibly_batched_index] /opt/conda/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py in <listcomp>(.0) 42 def fetch(self, possibly_batched_index): 43 if self.auto_collation: ---> 44 data = [self.dataset[idx] for idx in possibly_batched_index] 45 else: 46 data = self.dataset[possibly_batched_index] /opt/conda/lib/python3.6/site-packages/torchio/data/dataset.py in __getitem__(self, index) 83 # Apply transform (this is usually the bottleneck) 84 if self._transform is not None: ---> 85 subject = self._transform(subject) 86 return subject 87 /opt/conda/lib/python3.6/site-packages/torchio/transforms/transform.py in __call__(self, data) 119 subject = copy.copy(subject) 120 with np.errstate(all='raise'): --> 121 transformed = self.apply_transform(subject) 122 if self.keep is not None: 123 for name, image in images_to_keep.items(): /opt/conda/lib/python3.6/site-packages/torchio/transforms/augmentation/composition.py in apply_transform(self, subject) 45 def apply_transform(self, subject: Subject) -> Subject: 46 for transform in self.transforms: ---> 47 subject = transform(subject) 48 return subject 49 /opt/conda/lib/python3.6/site-packages/torchio/transforms/transform.py in __call__(self, data) 119 subject = copy.copy(subject) 120 with np.errstate(all='raise'): --> 121 transformed = self.apply_transform(subject) 122 if self.keep is not None: 123 for name, image in images_to_keep.items(): /opt/conda/lib/python3.6/site-packages/torchio/transforms/augmentation/spatial/random_flip.py in apply_transform(self, subject) 57 } 58 transform = Flip(**self.add_include_exclude(arguments)) ---> 59 transformed = transform(subject) 60 return transformed 61 /opt/conda/lib/python3.6/site-packages/torchio/transforms/transform.py in __call__(self, data) 119 subject = copy.copy(subject) 120 with np.errstate(all='raise'): --> 121 transformed = self.apply_transform(subject) 122 if self.keep is not None: 123 for name, image in images_to_keep.items(): /opt/conda/lib/python3.6/site-packages/torchio/transforms/augmentation/spatial/random_flip.py in apply_transform(self, subject) 88 axes = _ensure_axes_indices(subject, self.axes) 89 for image in self.get_images(subject): ---> 90 _flip_image(image, axes) 91 return subject 92 /opt/conda/lib/python3.6/site-packages/torchio/transforms/augmentation/spatial/random_flip.py in _flip_image(image, axes) 125 spatial_axes = np.array(axes) + 1 126 data = image.numpy() --> 127 data = np.flip(data, axis=spatial_axes) 128 data = data.copy() # remove negative strides 129 data = torch.as_tensor(data) /opt/conda/lib/python3.6/site-packages/numpy/lib/function_base.py in flip(m, axis) 204 indexer = [slice(None)] * m.ndim 205 try: --> 206 indexer[axis] = slice(None, None, -1) 207 except IndexError: 208 raise ValueError("axis=%i is invalid for the %i-dimensional input array" TypeError: only integer scalar arrays can be converted to a scalar indexBeta Was this translation helpful? Give feedback.
All reactions