There will be a lot of nooby questions. I have searched for very long but for no avail, so if you find it similar to some question please link.
this is my structure of data. How do i access it?
this is my code. There are similar folders for validation(as ‘val’) and training(as ‘train’).
path = Path('../input/facial-expression-dataset-image-folders-fer2013/data')
data = ImageDataBunch.from_folder(path, train= path/'train',valid =path/'val',test = path/'test', ds_tfms=get_transforms(), size =64, num_workers = 0).normalize(imagenet_stats)
and gives the error: index 0 is out of bounds for axis 0 with size 0
The whole traceback:
IndexError Traceback (most recent call last)
in ()
----> 1 data = ImageDataBunch.from_folder(path, train= path/‘train’,valid =path/‘val’,test = path/‘test’, ds_tfms=get_transforms(), size =64, num_workers = 0).normalize(imagenet_stats)
/opt/conda/lib/python3.6/site-packages/fastai/vision/data.py in from_folder(cls, path, train, valid, valid_pct, classes, **kwargs)
113 if valid_pct is None: src = il.split_by_folder(train=train, valid=valid)
114 else: src = il.random_split_by_pct(valid_pct)
–> 115 src = src.label_from_folder(classes=classes)
116 return cls.create_from_ll(src, **kwargs)
117
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in _inner(*args, **kwargs)
407 assert isinstance(fv, Callable)
408 def _inner(*args, **kwargs):
–> 409 self.train = ft(*args, **kwargs)
410 assert isinstance(self.train, LabelList)
411 kwargs[‘label_cls’] = self.train.y.class
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in label_from_folder(self, **kwargs)
248 def label_from_folder(self, **kwargs)->‘LabelList’:
249 “Give a label to each filename depending on its folder.”
–> 250 return self.label_from_func(func=lambda o: o.parts[-2], **kwargs)
251
252 def label_from_re(self, pat:str, full_path:bool=False, **kwargs)->‘LabelList’:
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in label_from_func(self, func, **kwargs)
244 def label_from_func(self, func:Callable, **kwargs)->‘LabelList’:
245 “Apply func
to every input to get its label.”
–> 246 return self.label_from_list([func(o) for o in self.items], **kwargs)
247
248 def label_from_folder(self, **kwargs)->‘LabelList’:
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in label_from_list(self, labels, **kwargs)
220 “Label self.items
with labels
.”
221 labels = array(labels, dtype=object)
–> 222 label_cls = self.get_label_cls(labels, **kwargs)
223 y = label_cls(labels, path=self.path, **kwargs)
224 res = self._label_list(x=self, y=y)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in get_label_cls(self, labels, label_cls, sep, **kwargs)
210 if label_cls is not None: return label_cls
211 if self.label_cls is not None: return self.label_cls
–> 212 it = index_row(labels,0)
213 if sep is not None: return MultiCategoryList
214 if isinstance(it, (float, np.float32)): return FloatList
/opt/conda/lib/python3.6/site-packages/fastai/core.py in index_row(a, idxs)
221 if isinstance(res,(pd.DataFrame,pd.Series)): return res.copy()
222 return res
–> 223 return a[idxs]
224
225 def func_args(func)->bool:
Thank You