Okay, I rebuilt my data so that my “sketches” and “reps” are basically separate data sets, each with their own train and valid folders. This gets me a little further, but I hit this error:
AttributeError Traceback (most recent call last)
<ipython-input-40-0f553cce9c41> in <module>
5 .label_from_folder()
6 .databunch(bs=16))
----> 7 data.show_batch()
~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_data.py in show_batch(self, rows, ds_type, **kwargs)
149 def show_batch(self, rows:int=5, ds_type:DatasetType=DatasetType.Train, **kwargs)->None:
150 "Show a batch of data in `ds_type` on a few `rows`."
--> 151 x,y = self.one_batch(ds_type, True, True)
152 if self.train_ds.x._square_show: rows = rows ** 2
153 xs = [self.train_ds.x.reconstruct(grab_idx(x, i, self._batch_first)) for i in range(rows)]
~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_data.py in one_batch(self, ds_type, detach, denorm)
132 w = self.num_workers
133 self.num_workers = 0
--> 134 try: x,y = next(iter(dl))
135 finally: self.num_workers = w
136 if detach: x,y = to_detach(x),to_detach(y)
~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_data.py in __iter__(self)
68 for b in self.dl:
69 y = b[1][0] if is_listy(b[1]) else b[1]
---> 70 if not self.skip_size1 or y.size(0) != 1: yield self.proc_batch(b)
71
72 @classmethod
AttributeError: 'str' object has no attribute 'size'
It seems clear that it’s expecting an image but getting a string. My ImageTupleList
is basically identical to the tutorial, except that my get()
uses i
directly on itemsB
, rather than getting a random image:
def get(self, i):
# get the ith sketch
img1 = super().get(i)
# and the corresponding ith rep
fn = self.itemsB[i]
return ImageTuple(img1, open_image(fn))
Any thoughts on why it would still have a string (presumably a path) rather than an image, at this stage? My get()
is clearly returning an ImageTuple
, but I can’t see whether that is actually called by the dataloader (I’m quite new to python, so finding my way through the source is a bit tricky).
UPDATE: It seems like train_dl
and valid_dl
are somehow not the correct types. But how can that be???