Hello ! I am having the same error as @Vikasj (but with AttributeError: ‘PngImageFile’ object has no attribute ‘shape’)
Do you have any idea how to solve it ?
AttributeError Traceback (most recent call last)
in ()
3
4 trn_tfms, val_tfrms = tfms_from_model(arch, sz)
----> 5 im = val_tfrms(Image.open(f’{PATH}valid/dogs/arnaud.jpg’))
6 log_probs = to_np(learn.models.model(V(T(im[None]).cuda())))
7 preds = np.argmax(log_probs, axis=1)
~/fastai/courses/dl1/fastai/transforms.py in call(self, im, y)
501 crop_tfm = crop_fn_lu[crop_type](sz, tfm_y, sz_y)
502 self.tfms = tfms + [crop_tfm, normalizer, ChannelOrder(tfm_y)]
–> 503 def call(self, im, y=None): return compose(im, y, self.tfms)
504 def repr(self): return str(self.tfms)
505
~/fastai/courses/dl1/fastai/transforms.py in compose(im, y, fns)
482 for fn in fns:
483 #pdb.set_trace()
–> 484 im, y =fn(im, y)
485 return im if y is None else (im, y)
486
~/fastai/courses/dl1/fastai/transforms.py in call(self, x, y)
172 def call(self, x, y):
173 self.set_state()
–> 174 x,y = ((self.transform(x),y) if self.tfm_y==TfmType.NO
175 else self.transform(x,y) if self.tfm_y in (TfmType.PIXEL, TfmType.CLASS)
176 else self.transform_coord(x,y))
~/fastai/courses/dl1/fastai/transforms.py in transform(self, x, y)
180
181 def transform(self, x, y=None):
–> 182 x = self.do_transform(x,False)
183 return (x, self.do_transform(y,True)) if y is not None else x
184
~/fastai/courses/dl1/fastai/transforms.py in do_transform(self, x, is_y)
306 def do_transform(self, x, is_y):
307 if is_y: return scale_min(x, self.sz_y, cv2.INTER_NEAREST)
–> 308 else : return scale_min(x, self.sz, cv2.INTER_AREA )
309
310
~/fastai/courses/dl1/fastai/transforms.py in scale_min(im, targ, interpolation)
10 targ (int): target size
11 “”"
—> 12 r,c,*_ = im.shape
13 ratio = targ/min(r,c)
14 sz = (scale_to(c, ratio, targ), scale_to(r, ratio, targ))
AttributeError: ‘PngImageFile’ object has no attribute ‘shape’