Getting error when trying to distinguish between 5 different datasets

Hi, i was trying to distinguish between 5 different datasets.
cardboard , glass, metal ,paper ,plastic, trash.

when I passed these inputs to the 3 line code mentioned in lesson1.pynb file,
arch=resnet34
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, 224))
learn = ConvLearner.pretrained(arch, data, precompute=False)
learn.fit(0.01, 3)

I am facing this issue. Please help.

Sorry the error is a bit lengthy.

Epoch
0% 0/3 [00:00<?, ?it/s]

14%|█▍ | 4/29 [00:02<00:17, 1.45it/s, loss=2.28]Is a directory: data/dataset-resized/train/glass/.ipynb_checkpoints
21%|██ | 6/29 [00:03<00:13, 1.73it/s, loss=2.13]Is a directory: data/dataset-resized/train/paper/.ipynb_checkpoints
28%|██▊ | 8/29 [00:04<00:11, 1.90it/s, loss=2.02]Is a directory: data/dataset-resized/train/trash/.ipynb_checkpoints
Is a directory: data/dataset-resized/train/metal/.ipynb_checkpoints
31%|███ | 9/29 [00:04<00:10, 1.97it/s, loss=1.95]Is a directory: data/dataset-resized/train/plastic/.ipynb_checkpoints
38%|███▊ | 11/29 [00:05<00:08, 2.03it/s, loss=1.84]Is a directory: data/dataset-resized/train/cardboard/.ipynb_checkpoints


AttributeError Traceback (most recent call last)
in ()
2 data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, 224))
3 learn = ConvLearner.pretrained(arch, data, precompute=False)
----> 4 learn.fit(0.01, 3)

~/fastai/courses/dl1/fastai/learner.py in fit(self, lrs, n_cycle, wds, **kwargs)
211 self.sched = None
212 layer_opt = self.get_layer_opt(lrs, wds)
–> 213 self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
214
215 def warm_up(self, start_lr=1e-5, end_lr=10, wds=None):

~/fastai/courses/dl1/fastai/learner.py in fit_gen(self, model, data, layer_opt, n_cycle, cycle_len, cycle_mult, cycle_save_name, metrics, callbacks, use_wd_sched, norm_wds, wds_sched_mult, **kwargs)
158 n_epoch = sum_geom(cycle_len if cycle_len else 1, cycle_mult, n_cycle)
159 fit(model, data, n_epoch, layer_opt.opt, self.crit,
–> 160 metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, **kwargs)
161
162 def get_layer_groups(self): return self.models.get_layer_groups()

~/fastai/courses/dl1/fastai/model.py in fit(model, data, epochs, opt, crit, metrics, callbacks, **kwargs)
84 stepper.reset(True)
85 t = tqdm(iter(data.trn_dl), leave=False, total=len(data.trn_dl))
—> 86 for (*x,y) in t:
87 batch_num += 1
88 for cb in callbacks: cb.on_batch_begin()

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tqdm/_tqdm.py in iter(self)
951 “”", fp_write=getattr(self.fp, ‘write’, sys.stderr.write))
952
–> 953 for obj in iterable:
954 yield obj
955 # Update and possibly print the progressbar.

~/fastai/courses/dl1/fastai/dataset.py in next(self)
241 if self.i>=len(self.dl): raise StopIteration
242 self.i+=1
–> 243 return next(self.it)
244
245 @property

~/fastai/courses/dl1/fastai/dataloader.py in iter(self)
73 def iter(self):
74 with ThreadPoolExecutor(max_workers=self.num_workers) as e:
—> 75 for batch in e.map(self.get_batch, iter(self.batch_sampler)):
76 yield get_tensor(batch, self.pin_memory)
77

~/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())

~/anaconda3/envs/fastai/lib/python3.6/concurrent/futures/_base.py in result(self, timeout)
423 raise CancelledError()
424 elif self._state == FINISHED:
–> 425 return self.__get_result()
426
427 self._condition.wait(timeout)

~/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

~/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)

~/fastai/courses/dl1/fastai/dataloader.py in get_batch(self, indices)
66
67 def get_batch(self, indices):
—> 68 res = self.collate_fn([self.dataset[i] for i in indices], self.pad_idx)
69 if not self.transpose: return res
70 res[0] = res[0].T

~/fastai/courses/dl1/fastai/dataloader.py in (.0)
66
67 def get_batch(self, indices):
—> 68 res = self.collate_fn([self.dataset[i] for i in indices], self.pad_idx)
69 if not self.transpose: return res
70 res[0] = res[0].T

~/fastai/courses/dl1/fastai/dataset.py in getitem(self, idx)
95 def getitem(self, idx):
96 x,y = self.get_x(idx),self.get_y(idx)
—> 97 return self.get(self.transform, x, y)
98
99 def len(self): return self.n

~/fastai/courses/dl1/fastai/dataset.py in get(self, tfm, x, y)
100
101 def get(self, tfm, x, y):
–> 102 return (x,y) if tfm is None else tfm(x,y)
103
104 @abstractmethod

~/fastai/courses/dl1/fastai/transforms.py in call(self, im, y)
463 if crop_type == CropType.NO: crop_tfm = NoCropXY(sz, tfm_y)
464 self.tfms = tfms + [crop_tfm, normalizer, channel_dim]
–> 465 def call(self, im, y=None): return compose(im, y, self.tfms)
466
467

~/fastai/courses/dl1/fastai/transforms.py in compose(im, y, fns)
444 def compose(im, y, fns):
445 for fn in fns:
–> 446 im, y =fn(im, y)
447 return im if y is None else (im, y)
448

~/fastai/courses/dl1/fastai/transforms.py in call(self, x, y)
229 def call(self, x, y):
230 self.set_state()
–> 231 x,y = ((self.transform(x),y) if self.tfm_y==TfmType.NO
232 else self.transform(x,y) if self.tfm_y==TfmType.PIXEL
233 else self.transform_coord(x,y))

~/fastai/courses/dl1/fastai/transforms.py in transform(self, x, y)
237
238 def transform(self, x, y=None):
–> 239 x = self.do_transform(x)
240 return (x, self.do_transform(y)) if y is not None else x
241

~/fastai/courses/dl1/fastai/transforms.py in do_transform(self, x)
323
324 def do_transform(self, x):
–> 325 return scale_min(x, self.sz)
326
327

~/fastai/courses/dl1/fastai/transforms.py in scale_min(im, targ)
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: ‘NoneType’ object has no attribute ‘shape’

This error has been solved a lot of times…

Please Search the forums…

@ecdrid,
I am having a senior moment:

What does

for (*x,y) in t:

do?

I am getting a similar error in nlp.ipynb I wonder why the notebook is not updated.

Can you help?

Thanks