Hi there,
I’m trying to get a grip on the new fastai version.
I failed trying to show examples of data augmentations for dogs/cats. Any idea what’s going on?
data = image_data_from_folder(PATH, ds_tfms=get_transforms(), tfms=imagenet_norm)
ds = data.train_ds
data_tfms = DatasetTfm(ds, ds.tfms)
x,y = next(iter(data_tfms))
AssertionError Traceback (most recent call last)
in ()
1 ds = data.train_ds
2 data_tfms = DatasetTfm(ds, ds.tfms)
----> 3 x,y = next(iter(data_tfms))
~/fastai/fastai/vision/data.py in getitem(self, idx)
188 def getitem(self,idx:int)->Tuple[ItemBase,Any]:
189 “Return tfms(x),y.”
–> 190 x,y = self.ds[idx]
191 x = apply_tfms(self.tfms, x, **self.kwargs)
192 if self.tfm_y: y = apply_tfms(self.tfms, y, **self.y_kwargs)
~/fastai/fastai/vision/data.py in getitem(self, idx)
189 “Return tfms(x),y.”
190 x,y = self.ds[idx]
–> 191 x = apply_tfms(self.tfms, x, **self.kwargs)
192 if self.tfm_y: y = apply_tfms(self.tfms, y, **self.y_kwargs)
193 return x, y
~/fastai/fastai/vision/image.py in apply_tfms(tfms, x, do_resolve, xtra, size, mult, do_crop, padding_mode, **kwargs)
450 for tfm in tfms:
451 if tfm.tfm in xtra: x = tfm(x, **xtra[tfm.tfm])
–> 452 elif tfm in size_tfms: x = tfm(x, size=size, padding_mode=padding_mode)
453 else: x = tfm(x)
454 return x
~/fastai/fastai/vision/image.py in call(self, x, *args, **kwargs)
366 def call(self, x:Image, *args, **kwargs)->Image:
367 “Randomly execute our tfm on x
.”
–> 368 return self.tfm(x, *args, **{**self.resolved, **kwargs}) if self.do_run else x
369
370
~/fastai/fastai/vision/image.py in call(self, p, is_random, *args, **kwargs)
310 def call(self, *args:Any, p:float=1., is_random:bool=True, **kwargs:Any)->Image:
311 “Calc now if args
passed; else create a transform called prob p
if random
.”
–> 312 if args: return self.calc(*args, **kwargs)
313 else: return RandTransform(self, kwargs=kwargs, is_random=is_random, p=p)
314
~/fastai/fastai/vision/image.py in calc(self, x, *args, **kwargs)
315 def calc(self, x:Image, *args:Any, **kwargs:Any)->Image:
316 “Apply to image x
, wrapping it if necessary.”
–> 317 if self._wrap: return getattr(x, self._wrap)(self.func, *args, **kwargs)
318 else: return self.func(x, *args, **kwargs)
319
~/fastai/fastai/vision/image.py in pixel(self, func, *args, **kwargs)
152 def pixel(self, func:PixelFunc, *args, **kwargs)->‘Image’:
153 “Equivalent to image.px = func(image.px)
.”
–> 154 self.px = func(self.px, *args, **kwargs)
155 return self
156
~/fastai/fastai/vision/transform.py in crop_pad(x, size, padding_mode, row_pct, col_pct)
90 “Crop and pad tfm - row_pct
,col_pct
sets focal point.”
91 padding_mode = _pad_mode_convert[padding_mode]
—> 92 size = listify(size,2)
93 if x.shape[1:] == size: return x
94 rows,cols = size
~/fastai/fastai/core.py in listify(p, q)
84 n = q if type(q)==int else len§ if q is None else len(q)
85 if len§==1: p = p * n
—> 86 assert len§==n, f’List len mismatch ({len§} vs {n})’
87 return list§
88
AssertionError: List len mismatch (0 vs 2)