Apply transformations in inference also (v3)


I’m trying to do a binary classification.

I would like to know if there is a way, similar to TTA(), to apply the same transformation I used during training with aug_tfms to new images in the inference stage and get the average classification for the non augmented image.

For exemple if I have :

tfms = get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.05, max_warp=0.)
learn = load_learner(data_folder, test = ImageItemList.from_folder(data_folder/‘data_to_predict’))

Can I easily apply tfms on test and get the mean classification for each original image ?

Thank you !

The idea is based on this paper : Data Augmentation for Skin Lesion Analysis :

1 Like

I’m not aware of any obvious ways to do this. Maybe you could put the images in validation set and then use TTA, and do the mean yourself ?

Sadly TTA() doesn’t really apply tfms :(.

I’m not quite familiar with, is there a way to just apply the transforms done in training to a different set of images ?

I could do the mean myself after that :slight_smile:

yes, with the apply_tfms function.

1 Like