Can I define more complex transformations of the dataset after the standard ones in
tfms = tfms_from_model(resnet34, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
data = ImageClassifierData.from_paths(PATH, tfms=tfms)
I would like to do Fourier transform of already rotated, cropped and zoomed image. May be the file https://github.com/fastai/fastai/blob/master/fastai/transforms.py should be modified somehow.
A = np.exp(image)
A = np.fft.fft2(A)
I am looking at a similar problem.
Did you get it to work?
I gave up. But my current view is that this transform should be part of the model and not the
tfms. Now I am learning how to create a custom model.
I wrote a small test to convert the image to black-and-white:
def __init__(self, tfm_y=TfmType.NO):
self.tfm_y = tfm_y
def do_transform(self, x):
x[:, :, 0-2] = cv2.cvtColor(x, cv2.COLOR_BGR2GRAY)
Then I include it like this:
tfms = tfms_from_model(arch, IMAGE_SIZE, aug_tfms=[BWTransform()], max_zoom=1.1)
I don’t do any random stuff as I want to transform every image in that step.
(make sure that you set precompute to False - otherwise it will not do any transformation)
Thank you @moseroli! It works
@moseroli, how would you implement this in the newest version (1.x) of fastai? I would appreciate if you could update your answer.
Thanks in advance!