Reading notes by other classmates plus my own understanding, here is what I think.
When we specify what transforms to apply, we pass a size
tfms = tfms_from_model(f_model, sz, aug_tfms=transforms_top_down,
After the assignment,
tfms will pass to the data loader
ImageClassifierData.from_csv(...). One of the things the data loader does is to resize the images on the fly. In other words, the images go into the data loader in full size, and it ONLY resizes the image when it outputs them to the model via Python’s generator.
data.resize(int(sz * 1.3), 'tmp') allow us to resize the images in advanced. Here,
data.resize() takes a maximum size (e.g.
sz=64, so the maximum size is
int(sz * 1.3) =
83), so each image has dimension bigger than
sz * 1.3 will be resized. Since images can be rectangular,
data.resize() will make sure the smallest dimension to be
sz * 1.3 and center-crop it.
Importantly, it creates a resized copy of the entire dataset to a temporary folder
This technique will save you a lot of time because according to Jeremy, if you have large images, say 1000 by 1000, reading the images and resizing it to 64 by 64 before doing SGD during training will take more time than training the convolution nets alone! By calling
data.resize() in advanced, we can resize the images once and do SGD multiple times efficiently.