Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

TypeError: setup() takes from 1 to 2 positional arguments but 3 were given #40

Closed
muellerzr opened this issue Jan 8, 2020 · 1 comment

Comments

@muellerzr
Copy link
Contributor

Seems to be an issue with a recent commit, when attempting to databunch COCO I receive the following stack trace:

path = untar_data(URLs.COCO_SAMPLE)
dblock = DataBlock(blocks=(ImageBlock, ImageBlock),
                   get_items=get_image_files,
                   splitter=RandomSplitter(0.1, seed=42))
dbunch = dblock.databunch(path, bs=22, item_tfms=[Resize(224)],
                       batch_tfms=[Normalize.from_stats(*imagenet_stats)])

Stack Trace:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-129-76a6dc7939cf> in <module>()
      1 dbunch = dblock.databunch(path, bs=22, item_tfms=[Resize(224)],
----> 2                        batch_tfms=[Normalize.from_stats(*imagenet_stats)])

6 frames
/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in databunch(self, source, path, type_tfms, item_tfms, batch_tfms, **kwargs)
     80 
     81     def databunch(self, source, path='.', type_tfms=None, item_tfms=None, batch_tfms=None, **kwargs):
---> 82         dsrc = self.datasource(source, type_tfms=type_tfms)
     83         item_tfms  = _merge_tfms(self.default_item_tfms,  item_tfms)
     84         batch_tfms = _merge_tfms(self.default_batch_tfms, batch_tfms)

/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in datasource(self, source, type_tfms)
     77         type_tfms = L([self.default_type_tfms, type_tfms, labellers]).map_zip(
     78             lambda tt,tfm,l: L(l) + _merge_tfms(tt, tfm))
---> 79         return DataSource(items, tfms=type_tfms, splits=splits, dl_type=self.dl_type, n_inp=self.n_inp)
     80 
     81     def databunch(self, source, path='.', type_tfms=None, item_tfms=None, batch_tfms=None, **kwargs):

/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in __init__(self, items, tfms, tls, n_inp, dl_type, **kwargs)
    227     def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
    228         super().__init__(dl_type=dl_type)
--> 229         self.tls = L(tls if tls else [TfmdList(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
    230         self.n_inp = (1 if len(self.tls)==1 else len(self.tls)-1) if n_inp is None else n_inp
    231 

/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in <listcomp>(.0)
    227     def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
    228         super().__init__(dl_type=dl_type)
--> 229         self.tls = L(tls if tls else [TfmdList(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
    230         self.n_inp = (1 if len(self.tls)==1 else len(self.tls)-1) if n_inp is None else n_inp
    231 

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
     39             return x
     40 
---> 41         res = super().__call__(*((x,) + args), **kwargs)
     42         res._newchk = 0
     43         return res

/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in __init__(self, items, tfms, use_list, do_setup, as_item, split_idx, train_setup, splits, types)
    173         self.tfms = Pipeline(tfms, as_item=as_item, split_idx=split_idx)
    174         self.types = types
--> 175         if do_setup: self.setup(train_setup=train_setup)
    176 
    177     def _new(self, items, **kwargs): return super()._new(items, tfms=self.tfms, do_setup=False, types=self.types, **kwargs)

/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in setup(self, train_setup)
    186 
    187     def setup(self, train_setup=True):
--> 188         self.tfms.setup(self, train_setup)
    189         if len(self) != 0:
    190             x,self.types = super().__getitem__(0),[]

TypeError: setup() takes from 1 to 2 positional arguments but 3 were given
@sgugger
Copy link
Contributor

sgugger commented Jan 8, 2020

I think you have a conflict between latest fastcore and not latest fastai2. This should be fixed now (please reopen if it is not).

@sgugger sgugger closed this as completed Jan 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants