As we can see, almost 3 columns are getting cut out. Since each of the columns have a specific meaning, cutting them decreases accuracy. How can I fix this?
Here is the data bunch I am using: data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.20, size = 224 , num_workers=5)
If all the images are of same size in your dataset, then remove the size parameter from the Databunch declaration and it should most probably work. Try it out.
The size=224 parameter calls the resize transform behind the scenes.
By default, a single int, (such as in size=224, will resize AND crop the image to (224, 224).
If you want to just resize the image and squish it to (224,224), without cropping anything out, use size=(224,224)
Alternatively, if you’re images are already the same size, you can get rid of the size parameter entirely, as suggested by @navidpanchi.
Let me know if this helps!
See below for references & source link
resize
Pytorch’s transforms.Resize(size) equivalent is implemented without an explicit transform function in fastai. It’s done via the arguments size and resize_method .
The size argument can be either a single int224 , or a tuple of int s (224,400) . The default behavior is to crop the image to a square when a single int is passed and to squish it in the case of a tuple , so that:
if size=224 is passed, it will resize and then crop to (224,224)
if size=(224,400) is passed, it will squish it to (224,400)
if size=(224,224) is passed, it will squish (not crop!) it to (224,224)
Hey!
Yup, it worked. Just a pointer to anyone else who may encounter this. I had to set num_workers = 0 and reduce the batch size since without it I was encountering CUDA Out of memory errors. Thanks!