Test_ds for segmentation

When I was trying to perform an evaluation on a segmentation dataset to a test folder, I ran into a problem where it was trying to transform a dummy class value for a test folder because tfm_y=True gets applied to train, val, and test DatasetTfms. I worked around this, by disallowing transformation on the test dataset by setting tfm_y=False, but this assumes that the test set does not have y values for evaluation. Would it make more sense to include a SegmentationDataset.from_single_folder that populates a dummy_y with all zeros for transformation?

def transform_datasets(train_ds:Dataset, valid_ds:Dataset, test_ds:Optional[Dataset]=None,
                       tfms:Optional[Tuple[TfmList,TfmList]]=None, **kwargs:Any):
    "Create train, valid and maybe test DatasetTfm` using `tfms` = (train_tfms,valid_tfms)"
    res = [DatasetTfm(train_ds, tfms[0],  **kwargs),
           DatasetTfm(valid_ds, tfms[1],  **kwargs)]
    if test_ds is not None:
        kwargs['tfm_y'] = False # <----- ADDED LINE
        res.append(DatasetTfm(test_ds, tfms[1], **kwargs))
    return res
1 Like

Yes it would. We’ll change that after Tuesday.

1 Like