Dear all and team from fastai, recently I joined this wonderful course and this week I started working in a little project using the MNIST data set. While I was trying to do some transformations I think I found a bug (maybe) in the rand_zoom
method. So before open an issue in github I prefer to ask here first.
This is the minimum code required to reproduce the possible bug.
Starter code (by the way I’m working on colab with the latest fastai version 1.0.52)
from fastai.vision import *
path = untar_data(URLs.MNIST)
tfms = ([*rand_pad(padding=3, size=28, mode='zeros')], [])
im_list = ImageList.from_folder(path, convert_mode='L')
split_data = im_list.split_by_folder(train = 'training', valid = 'testing')
label_data = split_data.label_from_folder().transform(tfms)
data = label_data.databunch(bs=128).normalize()
and here is where the possible bug happens
def get_ex(): return data.train_ds[543][0]
tfm = rand_zoom(scale=(0.3,1.3))
_, axs = plt.subplots(3,3,figsize=(6,8))
for ax in axs.flatten():
img = get_ex().apply_tfms(tfm)
img.show(ax=ax)
I don’t know if this is the intended behavior for the rand_zoom
transformation but I was expecting a behavior more similar to the cat pictures depicted in the documentation
To be more specific, what I want to achieve is an effect similar to the one provided by these PyTorch transformations
transforms.Compose([transforms.RandomAffine(0,
translate=(0.15,0.15), shear=10, scale=(0.3,1.5)),
transforms.RandomRotation(10)
])
because I want to include the following kind of images for my data augmentation
I try to do the equivalent thing with the fastai
library and I thought this code
tfms = ([*rand_pad(padding=3, size=28, mode='zeros'),
rotate(degrees=10),
rand_zoom(scale=(0.6,1.3))], [])
will do the trick, but I found the aforementioned unexpected behavior. Is rand_zoom
working right? and If rand_zoom
is working properly, someone knows how I can scale the images in a similar fashion of scale=(0.3,1.5)
transformation from the torch library
Thanks