Best way to resize pictures for model training

I think this is mentioned in the fastai docs here

specifically note this excerpt:

You can also decide how your images are put to the final size by specifying a resize_method . By default, the library resize the image while keeping its original ratio so that the smaller size corresponds to the given size, then takes a crop ( ResizeMethod.CROP ). You can choose to resize the image while keeping its original ratio so that the bigger size corresponds to the given size, then take a pad ( ResizeeMethod.PAD ). Another way is to just squish the image to the given size ( ResizeeMethod.SQUISH ).

_,axs = plt.subplots(1,3,figsize=(9,3)) 
for rsz,ax in zip([ResizeMethod.CROP, ResizeMethod.PAD, ResizeMethod.SQUISH], axs): 
    get_ex().apply_tfms([crop_pad()], size=224, resize_method=rsz, padding_mode='zeros').show(ax=ax, title=rsz.name.lower())

download

7 Likes

I think that squashing doesn’t matter a lot as long as all time axes are squashed with the same amount. Maybe you can do some experiments with a small set of sonagrams.

Is there any way i can call RandomGrayscale of pytorch into verify_image function? I looked through code and looks like it is not supported. If so so then can i access learner class and set this value?