Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2018 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9140946b47097b0a8ca8bdd65ec09eaa to your computer and use it in GitHub Desktop.
Save anonymous/9140946b47097b0a8ca8bdd65ec09eaa to your computer and use it in GitHub Desktop.
IndexError Traceback (most recent call last)
<ipython-input-88-d54f5c5bb506> in <module>()
----> 1 x,y=next(iter(md.val_dl))
/mnt/fast/repos/fastai/courses/dl2/fastai/dataloader.py in __iter__(self)
80 else:
81 with ThreadPoolExecutor(max_workers=self.num_workers) as e:
---> 82 for batch in e.map(self.get_batch, iter(self.batch_sampler)):
83 yield get_tensor(batch, self.pin_memory)
84
/mnt/fast/anaconda3/envs/fastai/lib/python3.6/concurrent/futures/_base.py in result_iterator()
584 # Careful not to keep a reference to the popped future
585 if timeout is None:
--> 586 yield fs.pop().result()
587 else:
588 yield fs.pop().result(end_time - time.time())
/mnt/fast/anaconda3/envs/fastai/lib/python3.6/concurrent/futures/_base.py in result(self, timeout)
430 raise CancelledError()
431 elif self._state == FINISHED:
--> 432 return self.__get_result()
433 else:
434 raise TimeoutError()
/mnt/fast/anaconda3/envs/fastai/lib/python3.6/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result
/mnt/fast/anaconda3/envs/fastai/lib/python3.6/concurrent/futures/thread.py in run(self)
54
55 try:
---> 56 result = self.fn(*self.args, **self.kwargs)
57 except BaseException as exc:
58 self.future.set_exception(exc)
/mnt/fast/repos/fastai/courses/dl2/fastai/dataloader.py in get_batch(self, indices)
69
70 def get_batch(self, indices):
---> 71 res = self.np_collate([self.dataset[i] for i in indices])
72 if self.transpose: res[0] = res[0].T
73 if self.transpose_y: res[1] = res[1].T
/mnt/fast/repos/fastai/courses/dl2/fastai/dataloader.py in <listcomp>(.0)
69
70 def get_batch(self, indices):
---> 71 res = self.np_collate([self.dataset[i] for i in indices])
72 if self.transpose: res[0] = res[0].T
73 if self.transpose_y: res[1] = res[1].T
/mnt/fast/repos/fastai/courses/dl2/fastai/dataset.py in __getitem__(self, idx)
164 def __getitem__(self, idx):
165 x,y = self.get_x(idx),self.get_y(idx)
--> 166 return self.get(self.transform, x, y)
167
168 def __len__(self): return self.n
/mnt/fast/repos/fastai/courses/dl2/fastai/dataset.py in get(self, tfm, x, y)
169
170 def get(self, tfm, x, y):
--> 171 return (x,y) if tfm is None else tfm(x,y)
172
173 @abstractmethod
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in __call__(self, im, y)
433 crop_tfm = crop_fn_lu[crop_type](sz, tfm_y)
434 self.tfms = tfms + [crop_tfm, normalizer, channel_dim]
--> 435 def __call__(self, im, y=None): return compose(im, y, self.tfms)
436
437
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in compose(im, y, fns)
415 for fn in fns:
416 #pdb.set_trace()
--> 417 im, y =fn(im, y)
418 return im if y is None else (im, y)
419
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in __call__(self, x, y)
174 x,y = ((self.transform(x),y) if self.tfm_y==TfmType.NO
175 else self.transform(x,y) if self.tfm_y==TfmType.PIXEL
--> 176 else self.transform_coord(x,y))
177 return x, y
178
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in transform_coord(self, x, ys)
195 def transform_coord(self, x, ys):
196 yp = partition(ys, 4)
--> 197 y2 = [self.map_y(y,x) for y in yp]
198 x = self.do_transform(x, False)
199 return x, np.concatenate(y2)
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in <listcomp>(.0)
195 def transform_coord(self, x, ys):
196 yp = partition(ys, 4)
--> 197 y2 = [self.map_y(y,x) for y in yp]
198 x = self.do_transform(x, False)
199 return x, np.concatenate(y2)
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in map_y(self, y0, x)
189 """ A class that represents a coordinate transform. """
190 def map_y(self, y0, x):
--> 191 y = random_px_rect(y0, x)
192 y_tr = self.do_transform(y, True)
193 return to_bb(y_tr, y) if y_tr.sum()>1 else y0
/mnt/fast/repos/fastai/courses/dl2/fastai/transforms.py in random_px_rect(y, x)
323 r,c,*_ = x.shape
324 Y = np.zeros((r, c))
--> 325 Y[rows, cols] = 1
326 return Y
327
IndexError: index 383 is out of bounds for axis 0 with size 298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment