The 10_transforms.ipynb notebook throws a ValueError: empty range for randrange()
at the line
show_batch(next(iter(dl)))
in the “Random crop” section (please see below).
And a the same error occurred again in the cell under “Perspective warping” with
x = next(iter(dl))
show_batch(x)
Anyone know how to fix this? I am running Windows 10 64-bit.
Thanks!
ValueError Traceback (most recent call last)
in
----> 1 show_batch(next(iter(dl)))
~\Anaconda3\envs\fastai\lib\site-packages\torch\utils\data\dataloader.py in next(self)
527 if self.num_workers == 0: # same-process loading
528 indices = next(self.sample_iter) # may raise StopIteration
→ 529 batch = self.collate_fn([self.dataset[i] for i in indices])
530 if self.pin_memory:
531 batch = _utils.pin_memory.pin_memory_batch(batch)
~\Anaconda3\envs\fastai\lib\site-packages\torch\utils\data\dataloader.py in (.0)
527 if self.num_workers == 0: # same-process loading
528 indices = next(self.sample_iter) # may raise StopIteration
→ 529 batch = self.collate_fn([self.dataset[i] for i in indices])
530 if self.pin_memory:
531 batch = _utils.pin_memory.pin_memory_batch(batch)
~\fastai\fastai_docs\dev_course\dl2_jcat\exp\nb_08.py in getitem(self, idx)
54 res = super().getitem(idx)
55 if isinstance(res,list): return [self._get(o) for o in res]
—> 56 return self._get(res)
57
58 class ImageList(ItemList):
~\fastai\fastai_docs\dev_course\dl2_jcat\exp\nb_08.py in _get(self, i)
49
50 def get(self, i): return i
—> 51 def _get(self, i): return compose(self.get(i), self.tfms)
52
53 def getitem(self, idx):
~\fastai\fastai_docs\dev_course\dl2_jcat\exp\nb_08.py in compose(x, funcs, order_key, *args, **kwargs)
37 def compose(x, funcs, *args, order_key=‘_order’, **kwargs):
38 key = lambda o: getattr(o, order_key, 0)
—> 39 for f in sorted(listify(funcs), key=key): x = f(x, **kwargs)
40 return x
41
in call(self, x)
15 def call(self, x):
16 csize = default_crop_size(*x.size) if self.crop_size is None else self.crop_size
—> 17 return x.transform(self.size, PIL.Image.EXTENT, self.get_corners(*x.size, *csize), resample=self.resample)
18
19 def get_corners(self, w, h): return (0,0,w,h)
in get_corners(self, w, h, wc, hc)
25 class RandomCrop(GeneralCrop):
26 def get_corners(self, w, h,wc, hc):
—> 27 left,top = randint(0,w-wc),randint(0,h-hc)
28 return (left, top, left+wc, top+hc)
~\Anaconda3\envs\fastai\lib\random.py in randint(self, a, b)
220 “”"
221
→ 222 return self.randrange(a, b+1)
223
224 def _randbelow(self, n, int=int, maxsize=1<<BPF, type=type,
~\Anaconda3\envs\fastai\lib\random.py in randrange(self, start, stop, step, _int)
198 return istart + self._randbelow(width)
199 if step == 1:
→ 200 raise ValueError(“empty range for randrange() (%d,%d, %d)” % (istart, istop, width))
201
202 # Non-unit step argument supplied.
ValueError: empty range for randrange() (0,-5, -5)