How to apply aug transform to image and mask simultaneously in fastai v2?

Hey All,

My data block specification is as below:

dblock = DataBlock(blocks=(ImageBlock, MaskBlock(codes)),
get_items=get_image_files,
get_y = get_mask,
item_tfms=Resize(448),
batch_tfms=[*aug_transforms(size=224, min_scale=0.75), Normalize.from_stats(*severstal_stats)]
)

dls = dblock.dataloaders(path/‘train_images’,batch_size=4)

The aug_transforms are applied to images but not masks. See the output below:

Fastai v1 used to have something like tfm_y=True flag. How to do this in Fastai v2?

Appreciate any help.
Thanks
Bilal

it seems that doesn’t work with min_scale. If you remove it it works, also check with show_batch that it correctly i.e. flip the image and the max

Hey @Mugnaio,

Thanks a lot for this very useful information.

Yes it works when I drop the min_scale parameter. But in that case, I can’t use the RandomResizeCropped in the data augmentation. Is this is how it should be for segmentation tasks?