Validation show batch and resizing

Hi! I’m going through intro data to prepare some stuff (currently Jupyter Notebook 02_production), and I noticed that in the From Data to DataLoaders section, line

dls.valid.show_batch(max_n=4, nrows=1)

shows stretched images when using RandomResizedCrop(128, min_scale=0.3). If I use the default Resize(128) the validation batch looks cropped, but not deformed.

Things look normal for the train set. Note that the notebook changes the original dls.valid to dls.train when the new crop method is introduced, so this is probably the intended behaviour, and running the Notebook as is will not produce anything weird.

I just want to confirm that this is expected (and why), and to understand what to actually expect to happen for the validation images during training and inference.

If we look at the documentation for RandomSizedCrop we can see what’s going on here:

Squish is used on the validation set, removing val_xtra proportion of each side first.

However, for Resize we have:

On the validation set, the crop is always a center crop (on the dimension that’s cropped).

This difference in behaviour may be unexpected, but it is definitely working as intended.

1 Like

Please join the #active-study groups channel and join “Cluster of Stars” study group. We will have text discussion in the “Study Groups - cluster-of-stars” channel, and voice chat in the “fastai study groups channel”`! !