Normalize images + aug_transforms() in SegmentationDataLoaders

What is the proper way of resizing image, apply augmentation and normalize images in Fast AI v2?

SegmentationDataLoaders.from_label_func(path=path_manual,fnames=fnames_manual,
                                              label_func=get_y_fn_manual,valid_pct=0.1,
                                              codes=codes,bs=1,shuffle_train=True,
                                              item_tfms=Resize((size,size)),
                                              batch_tfms=aug_transforms(mult=1.0, do_flip=True, 
                                                                        flip_vert=True, max_rotate=10., 
                                                                        max_zoom=1.1,max_warp=0.2, 
                                                                        p_affine=0.75, p_lighting=0, 
                                                                        xtra_tfms=None))

If I pass to batch_tfms an array with next form:[aug_transforms(...),Normalize.from_stats(*imagenet_stats)] all I get is the next error: Could not do one pass in your dataloader, there is something wrong in it

2 Likes

aug_transforms(...) returns a list, so you need to star it if you put it in another list with additional transforms:

[*aug_transforms(...),Normalize.from_stats(*imagenet_stats)] 
1 Like

Thank you, very much. It solved my problem. I saw it on 04 Segmentation Notebook:

We used the *aug_transforms there too :wink: