I know we will cover this later in the course with the Carvana data set, but I wanted to try a few things on the Data Science Bowl competition on Kaggle.
There is a weird thing happening when you create an ImageData object and your desired targets are masks for the image. Specifically my code is
tfms = tfms_from_model(resnet34, size, crop_type=CropType.NO, tfm_y=TfmType.PIXEL, aug_tfms=aug_tfms)
datasets = ImageData.get_ds(ImagesMasksDataset, (trn_img,trn_msk), (val_img,val_msk), tfms, path=PATH)
md = ImageData(PATH, datasets, batch_size, num_workers=0, classes=None)
The TfmType.PIXEL seems perfect for this since I want all the transformations done on the inputs to be done on the masks as well. And it works like a charm on all the data augmentation operations as well as the resizing of the images, but it also does two annoying things: it flips the channels (I can live with that) and it normalizes the image, like it does for the inputs.
The normalization changes all the values of the target mask which we don’t want (or if we do, I really don’t see why).
Looking at the carvana notebook I tried to figure out a way to turn it off but I missed it completely so if someone knows how to do it easily, please let me know. For now, the hackey thing I did to get going is adding a line
tfms = tfms_from_model(resnet34, size, crop_type=CropType.NO, tfm_y=TfmType.PIXEL, aug_tfms=aug_tfms)
list(tfms[0].tfms)[-2].tfm_y = TfmType.NO
datasets = ImageData.get_ds(ImagesMasksDataset, (trn_img,trn_msk), (val_img,val_msk), tfms, path=PATH)
md = ImageData(PATH, datasets, batch_size, num_workers=0, classes=None)
since I saw the Normalize Transform was the second to last in the list of transforms, and I chose an option where it wouldn’t do anything.