I’m trying to write a custom transform for the webserver project from lesson, basically I want to crop the images a certain way since I know the location in the image I am interested in (bottom, center).
I’ve googled and read most of what I could find of relevant posts and documentation, but have been unable to make it work. I’ve tried various solutions, but what I have at the moment is
def do_crop(x): return crop(x, 500, row_pct=0.5, col_pct=1.0) cropper = TfmPixel(do_crop) path = Path('my_data_set') tfms = [cropper] # transforms = get_transforms(do_flip=False,max_zoom=1.0,max_rotate=0.0,max_warp=0.0) np.random.seed(42) data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2, ds_tfms=(tfms, tfms), size=224, num_workers=4).normalize(imagenet_stats)
I’ve also tried putting the custom transform inside xtra_tfms in get_transforms and using the transforms object, but I still get the same error.
It returns a warning
...fastai/basic_data.py:226: UserWarning: There seems to be something wrong with your dataset, can't access any element of self.train_ds.
If I use the transform object without my xtra_tfms it works, so clearly I am doing something wrong. Anyone able to shed some light on how to do this?
Some additional info that I am unsure if would be relevant; If I try to call data.show_batch(…) after trying to initialize the data, it says
AttributeError: 'TfmPixel' object has no attribute 'tfm'
Thanks in advance!