PR:
I was quite confuse with the SplitData
Class and the kwargs, I was able to pull up the semi-finish notebook only because of the lesson 3 notebook. I follow the SegmentationDataset closely and run the debugger step by step. I notice that even though x
and y
should be a file list, the argument passed when creating the dataset was actually an array, I cannot figure out this part yet.
class SegmentationDataset(ImageDataset):
"A dataset for segmentation task."
def __init__(self, x:FilePathList, y:FilePathList, classes:Collection[Any], div=False, convert_mode='L'):
class SplitData():
"Regroups `train` and `valid` data, inside a `path`."
path:PathOrStr
train:LabelList
valid:LabelList
.....omitted
def datasets(self, dataset_cls:type, **kwargs)->'SplitDatasets':
"Create datasets from the underlying data using `dataset_cls` and passing the `kwargs`."
dss = [dataset_cls(*self.train.items.T, **kwargs)]
kwg_cls = kwargs.pop('classes') if 'classes' in kwargs else None
if hasattr(dss[0], 'classes'): kwg_cls = dss[0].classes
if kwg_cls is not None: kwargs['classes'] = kwg_cls
dss.append(dataset_cls(*self.valid.items.T, **kwargs))
cls = getattr(dataset_cls, '__splits_class__', SplitDatasets)
return cls(self.path, *dss)
Notebook: