The VAR paper shows that its class-conditional generator can fill in parts of an image without any fine-tuning. For in-painting and out-painting it teacher-forces the ground-truth tokens outside the mask and lets the model generate only the tokens inside, with no class label; for class-conditional editing it generates only inside a box, conditioned on a class label. Implement this on the scale-by-scale generation loop, with greedy decoding.
coarse_masks(fine_mask, sides)
fine_mask is an boolean array at the resolution of the last map; True marks a cell to generate.sides ( divides ) return an boolean map whose cell is True when any of the fine cells it covers is True. (The paper does not say how a mask is carried to coarse maps; this rule is our choice.)var_inpaint(model, known_maps, fine_mask, label=None)
known_maps are the ground-truth token maps of the image (square, increasing sizes, the last of size ).model(label, prefix) returns logits of shape for the next map given the list of maps so far, as in plain generation.{"maps": [...], "generated": [number of generated tokens per scale], "calls": K}.ValueError if fine_mask does not have the shape of the last map or a size does not divide .