ImageDataBunch.from_df throws when adding transforms tfms TypeError: 'list' object is not callable

Posting this issue on forums first after following all instructions on github for posting issues

data = ImageDataBunch.from_df(path/'images', df, valid_pct=0.2, dl_tfms=tfms, size=size)
data.show_batch(rows=4, figsize=(12,9))

In two words, when I add transforms to ImageDataBunch it throws
Same code without transforms works just fine

TypeError                                 Traceback (most recent call last)
<ipython-input-18-8c112221dbf0> in <module>
      1 data = ImageDataBunch.from_df(path/'images', df, valid_pct=0.2, dl_tfms=tfms, size=size)
----> 2 data.show_batch(rows=4, figsize=(12,9))

/opt/conda/lib/python3.7/site-packages/fastai/ in show_batch(self, rows, ds_type, reverse, **kwargs)
    184     def show_batch(self, rows:int=5, ds_type:DatasetType=DatasetType.Train, reverse:bool=False, **kwargs)->None:
    185         "Show a batch of data in `ds_type` on a few `rows`."
--> 186         x,y = self.one_batch(ds_type, True, True)
    187         if reverse: x,y = x.flip(0),y.flip(0)
    188         n_items = rows **2 if self.train_ds.x._square_show else rows

/opt/conda/lib/python3.7/site-packages/fastai/ in one_batch(self, ds_type, detach, denorm, cpu)
    167         w = dl.num_workers
    168         dl.num_workers = 0
--> 169         try:     x,y = next(iter(dl))
    170         finally: dl.num_workers = w
    171         if detach: x,y = to_detach(x,cpu=cpu),to_detach(y,cpu=cpu)

/opt/conda/lib/python3.7/site-packages/fastai/ in __iter__(self)
     73     def __iter__(self):
     74         "Process and returns items from `DataLoader`."
---> 75         for b in self.dl: yield self.proc_batch(b)
     77     @classmethod

/opt/conda/lib/python3.7/site-packages/fastai/ in proc_batch(self, b)
     68         "Process batch `b` of `TensorImage`."
     69         b = to_device(b, self.device)
---> 70         for f in listify(self.tfms): b = f(b)
     71         return b

TypeError: 'list' object is not callable

All code to reproduce and errors are here (Version 4 is from master, Version 2 if from Kaggle installed version)

Sorry for a lot of warnings in Kaggle notebook, will be happy to know how to disable them too.

We can’t really help if we don’t know what it’s transforms. It should be a tuple with two lists of transforms IIRC, one for training and one for validation.

thank you for fast reply
transforms are

tfms = get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=2., max_warp=0.2, max_rotate=45)

How can I pass same or empty transforms for validation?

Oh, those should be passed to ds_tfms, not dl_tfms. Data augmentation on the GPU is in fastai v2.

1 Like

Thanks, that works!
I will delete notebook from public access as the issue was resolved