hi,friends.I’m a Chinese student. Recently, I’m learning fastai lesson 2, and I have some questions.I need your help!
(1)when I run this code
for c in classes:
print©
verify_images(path/c, delete=True, max_size=600)
why the result show me:C:\Users\dell\Anaconda3\lib\site-packages\fastprogress\fastprogress.py:105: UserWarning: Your generator is empty.
warn(“Your generator is empty.”)
(2)and when I this code:
np.random.seed(42)
data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2,
ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats)
the result is:
C:\Users\dell\Anaconda3\lib\site-packages\fastai\data_block.py:454: UserWarning: Your training set is empty. If this is by design, pass ignore_empty=True
to remove this warning.
warn(“Your training set is empty. If this is by design, pass ignore_empty=True
to remove this warning.”)
C:\Users\dell\Anaconda3\lib\site-packages\fastai\data_block.py:457: UserWarning: Your validation set is empty. If this is by design, use split_none()
or pass ignore_empty=True
when labelling to remove this warning.
or pass ignore_empty=True
when labelling to remove this warning.""")
IndexError Traceback (most recent call last)
in
1 np.random.seed(42)
2 data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2,
----> 3 ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats)
~\Anaconda3\lib\site-packages\fastai\vision\data.py in from_folder(cls, path, train, valid, test, valid_pct, seed, classes, **kwargs)
108 if valid_pct is None: src = il.split_by_folder(train=train, valid=valid)
109 else: src = il.split_by_rand_pct(valid_pct, seed)
–> 110 src = src.label_from_folder(classes=classes)
111 return cls.create_from_ll(src, test=test, **kwargs)
112
~\Anaconda3\lib\site-packages\fastai\data_block.py in _inner(*args, **kwargs)
473 assert isinstance(fv, Callable)
474 def _inner(*args, **kwargs):
–> 475 self.train = ft(*args, from_item_lists=True, **kwargs)
476 assert isinstance(self.train, LabelList)
477 kwargs[‘label_cls’] = self.train.y.class
~\Anaconda3\lib\site-packages\fastai\data_block.py in label_from_folder(self, label_cls, **kwargs)
302 “Give a label to each filename depending on its folder.”
303 return self.label_from_func(func=lambda o: (o.parts if isinstance(o, Path) else o.split(os.path.sep))[-2],
–> 304 label_cls=label_cls, **kwargs)
305
306 def label_from_re(self, pat:str, full_path:bool=False, label_cls:Callable=None, **kwargs)->‘LabelList’:
~\Anaconda3\lib\site-packages\fastai\data_block.py in label_from_func(self, func, label_cls, **kwargs)
297 def label_from_func(self, func:Callable, label_cls:Callable=None, **kwargs)->‘LabelList’:
298 “Apply func
to every input to get its label.”
–> 299 return self._label_from_list([func(o) for o in self.items], label_cls=label_cls, **kwargs)
300
301 def label_from_folder(self, label_cls:Callable=None, **kwargs)->‘LabelList’:
~\Anaconda3\lib\site-packages\fastai\data_block.py in _label_from_list(self, labels, label_cls, from_item_lists, **kwargs)
272 raise Exception(“Your data isn’t split, if you don’t want a validation set, please use split_none
.”)
273 labels = array(labels, dtype=object)
–> 274 label_cls = self.get_label_cls(labels, label_cls=label_cls, **kwargs)
275 y = label_cls(labels, path=self.path, **kwargs)
276 res = self._label_list(x=self, y=y)
~\Anaconda3\lib\site-packages\fastai\data_block.py in get_label_cls(self, labels, label_cls, label_delim, **kwargs)
261 if self.label_cls is not None: return self.label_cls
262 if label_delim is not None: return MultiCategoryList
–> 263 it = index_row(labels,0)
264 if isinstance(it, (float, np.float32)): return FloatList
265 if isinstance(try_int(it), (str, Integral)): return CategoryList
~\Anaconda3\lib\site-packages\fastai\core.py in index_row(a, idxs)
274 if isinstance(res,(pd.DataFrame,pd.Series)): return res.copy()
275 return res
–> 276 return a[idxs]
277
278 def func_args(func)->bool:
IndexError: index 0 is out of bounds for axis 0 with size 0
Ask for your help!