Get transform + Predict on numpy array

Hello,

I would like to predict on the new image in form of numpy arrays. To get the accurate result, the image must go through the same transformation as training set ( of course, we need to turn off the augmentation). Does anyone know how to get the test/valid transform from vision learner to make sure that test/valid transform is same as train transform?

Many thanks!!

1 Like

When you create your databunch you can manually collect that information.

src = (ImageList.from_folder(path)
                .split_by_folder()
                .label_from_folder()
                .transform(get_transforms(), size=(32,32))

# To get the transforms
train_tfms = src.train.tfms
val_tfms = src.valid.tfms

Thanks for your response. Is there a way to get these transforms from ImageDatabunch or cnn_learner? One of difficulty is that not all the transformation is in the transform but also in the preprocessor. That makes it difficult to apply for the new image/dataset if it is not come from the supported type of fastai.

You can manually check the preprocessor (only a single class to look at). I could not find a way to get the transforms directly from the learner.