PLANET_SAMPLE - Error "Your validation data contains a label"

Hello,

I went through Lesson 1 and tried to replicate the lesson by using Planet_Sample datasource. I’ve tried a couple of ImageDataBunch using from_csv and from_df but both of them give me the an error message
“Your validation data contains a label that isn’t present in the training set, please fix your data”

I even tried following the below article but even the sample code fails with the same error
https://docs.fast.ai/vision.data.html#ImageDataBunch.from_df
How do I resolve this? Full error below.


KeyError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process_one(self, item)
281 def process_one(self,item):
–> 282 try: return self.c2i[item] if item is not None else None
283 except:

KeyError: ‘clear conventional_mine primary road’

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
in ()
3 #path_labels = path/‘labels.csv’
4 #data = ImageDataBunch.from_df(path_img, df, ds_tfms=get_transforms(), size=28, num_workers=0, suffix=’.jpg’) #df,ds_tfms=get_transforms(), size=224, bs=bs, num_workers=0).normalize(imagenet_stats)
----> 5 data = ImageDataBunch.from_csv(path,folder=‘train’,size=128, suffix=’.jpg’, label_delim=’ ',ds_tfms=get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.05, max_warp=0.))

/opt/conda/lib/python3.6/site-packages/fastai/vision/data.py in from_csv(cls, path, folder, sep, csv_labels, valid_pct, fn_col, label_col, suffix, header, **kwargs)
134 df = pd.read_csv(path/csv_labels, header=header)
135 return cls.from_df(path, df, folder=folder, sep=sep, valid_pct=valid_pct,
–> 136 fn_col=fn_col, label_col=label_col, suffix=suffix, **kwargs)
137
138 @classmethod

/opt/conda/lib/python3.6/site-packages/fastai/vision/data.py in from_df(cls, path, df, folder, sep, valid_pct, fn_col, label_col, suffix, **kwargs)
123 src = (ImageItemList.from_df(df, path=path, folder=folder, suffix=suffix, cols=fn_col)
124 .random_split_by_pct(valid_pct)
–> 125 .label_from_df(sep=sep, cols=label_col))
126 return cls.create_from_ll(src, **kwargs)
127

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in _inner(*args, **kwargs)
412 self.valid = fv(*args, **kwargs)
413 self.class = LabelLists
–> 414 self.process()
415 return self
416 return _inner

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process(self)
459 “Process the inner datasets.”
460 xp,yp = self.get_processors()
–> 461 for i,ds in enumerate(self.lists): ds.process(xp, yp, filter_missing_y=i==0)
462 return self
463

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process(self, xp, yp, filter_missing_y)
584 def process(self, xp:PreProcessor=None, yp:PreProcessor=None, filter_missing_y:bool=False):
585 “Launch the processing on self.x and self.y with xp and yp.”
–> 586 self.y.process(yp)
587 if filter_missing_y and (getattr(self.x, ‘filter_missing_y’, None)):
588 filt = array([o is None for o in self.y])

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process(self, processor)
66 if processor is not None: self.processor = processor
67 self.processor = listify(self.processor)
—> 68 for p in self.processor: p.process(self)
69 return self
70

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process(self, ds)
288 ds.classes = self.classes
289 ds.c2i = self.c2i
–> 290 super().process(ds)
291
292 def getstate(self): return {‘classes’:self.classes}

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process(self, ds)
36 def init(self, ds:Collection=None): self.ref_ds = ds
37 def process_one(self, item:Any): return item
—> 38 def process(self, ds:Collection): ds.items = array([self.process_one(item) for item in ds.items])
39
40 class ItemList():

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in (.0)
36 def init(self, ds:Collection=None): self.ref_ds = ds
37 def process_one(self, item:Any): return item
—> 38 def process(self, ds:Collection): ds.items = array([self.process_one(item) for item in ds.items])
39
40 class ItemList():

/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in process_one(self, item)
282 try: return self.c2i[item] if item is not None else None
283 except:
–> 284 raise Exception(“Your validation data contains a label that isn’t present in the training set, please fix your data.”)
285
286 def process(self, ds):

Exception: Your validation data contains a label that isn’t present in the training set, please fix your data.