Esser and colleagues pretrain at pixels and then finetune at a target resolution with mixed aspect ratios. Each batch holds images of one size from a set of buckets with . The model uses 2-D frequency embeddings of patch positions, so it needs position coordinates for every patch, and simply interpolating the grid would not reflect the side lengths. One patch covers pixels (a factor 8 in the autoencoder and 2 in patching).
From the buckets take the largest height and the largest width and set , , . The full vertical grid is
and the horizontal grid is the same with . An image of pixels has rows and columns of patches; its coordinates are a centre crop of the full grids: rows from index , of them, and columns from , of them.
position_grid(H, W, S, buckets)
buckets is a non-empty list of (height, width) pairs in pixels; is one of the image sizes (it must fit inside )."rows" (list of floats), "cols" (list of floats) and "shape" (the tuple (h, w)).ValueError if , , or any bucket side is not a positive multiple of 16, or if or .