02_dls = bears.dataloaders(path) TypeError: 'NoneType' object is not iterable

Hi,I just learn it for two days and when I run
dls = bears.dataloaders(path)
and the result is below

Blockquote
TypeError Traceback (most recent call last)
in
----> 1 dls = bears.dataloaders(path)

~\anaconda3\lib\site-packages\fastai\data\block.py in dataloaders(self, source, path, verbose, **kwargs)
111
112 def dataloaders(self, source, path=’.’, verbose=False, **kwargs):
–> 113 dsets = self.datasets(source)
114 kwargs = {**self.dls_kwargs, **kwargs, ‘verbose’: verbose}
115 return dsets.dataloaders(path=path, after_item=self.item_tfms, after_batch=self.batch_tfms, **kwargs)

~\anaconda3\lib\site-packages\fastai\data\block.py in datasets(self, source, verbose)
108 splits = (self.splitter or RandomSplitter())(items)
109 pv(f"{len(splits)} datasets of sizes {’,’.join([str(len(s)) for s in splits])}", verbose)
–> 110 return Datasets(items, tfms=self._combine_type_tfms(), splits=splits, dl_type=self.dl_type, n_inp=self.n_inp, verbose=verbose)
111
112 def dataloaders(self, source, path=’.’, verbose=False, **kwargs):

~\anaconda3\lib\site-packages\fastai\data\core.py in init(self, items, tfms, tls, n_inp, dl_type, **kwargs)
308 def init(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
309 super().init(dl_type=dl_type)
–> 310 self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
311 self.n_inp = ifnone(n_inp, max(1, len(self.tls)-1))
312

~\anaconda3\lib\site-packages\fastai\data\core.py in (.0)
308 def init(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
309 super().init(dl_type=dl_type)
–> 310 self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
311 self.n_inp = ifnone(n_inp, max(1, len(self.tls)-1))
312

~\anaconda3\lib\site-packages\fastcore\foundation.py in call(cls, x, *args, **kwargs)
161 def call(cls, x=None, *args, **kwargs):
162 if not args and not kwargs and x is not None and isinstance(x,cls): return x
–> 163 return super().call(x, *args, **kwargs)
164
165 # Cell

~\anaconda3\lib\site-packages\fastai\data\core.py in init(self, items, tfms, use_list, do_setup, split_idx, train_setup, splits, types, verbose, dl_type)
234 if do_setup:
235 pv(f"Setting up {self.tfms}", verbose)
–> 236 self.setup(train_setup=train_setup)
237
238 def _new(self, items, split_idx=None, **kwargs):

~\anaconda3\lib\site-packages\fastai\data\core.py in setup(self, train_setup)
258 x = f(x)
259 self.types.append(type(x))
–> 260 types = L(t if is_listy(t) else [t] for t in self.types).concat().unique()
261 self.pretty_types = ‘\n’.join([f’ - {t}’ for t in types])
262

TypeError: ‘NoneType’ object is not iterable

what should I do to solve it?

HI @zh369437558,

Can you please share your code so that we can better assist you ?

Charles

1 Like


1 Like

I found that my in [51] can’t get anything.and maybe it’s the reason i get wrong.What’s the reason it can’t get any picture?

I found the answer of you in other question and it did work to download the image.and it solve this problem.https://forums.fast.ai/t/getting-the-bing-image-search-key/67417/33?u=zh369437558

I get the same error… I don’t think the solution located at https://forums.fast.ai/t/getting-the-bing-image-search-key/67417/33?u=zh369437558 applies here.

1 Like

I’m getting this error anyone knows how to solve it? I’m just running the chapter 2 code on colab and changed the bing to ddg as Jeremy told us to do in the lecture. Anything you guys think I’m missing?

If you are using search_images_ddg @laeeq51,Change the following cell to:

if not path.exists():
path.mkdir()
for o in bear_types:
dest = (path/o)
dest.mkdir(exist_ok=True)
results = search_images_ddg(f’{o} bear’)
download_images(dest, urls=results)

Basically You guys have to change the code that actually pulls the images and remove the .gotatrr() on the last line of the code block as well as search_images_bing to search_images_ddg. The first oneline call with search_images_ddg is not meant to actually pull the dataset.