Expand description
GLM-5.3 (Glm5NextImageProcessor) image geometry: smart_resize to a
patch × merge-aligned canvas, aspect-preserving fit, zero pad.
Split from vision_preprocess.rs for the file-size cap, and because the
resize POLICY differs from the Qwen family’s in a way that is not a
parameter: Qwen resizes straight onto the snapped canvas (accepting a
sub-grid-unit aspect distortion), GLM fits the content inside it and pads
the remainder. Two policies, two functions.
Functions§
- block_
major_ patch_ index - Index of the patch at
(patch_row, patch_col)in the 2×2-block-major stream the GLM tower expects. - pixel_
bounds - The area bounds this checkpoint permits, in pixels.
- resize_
and_ pad - Fit
imginside thesmart_resizecanvas preserving aspect, then zero-pad right/bottom to the canvas exactly. Returns the padded canvas. - smart_
resize - Qwen2-VL-family
smart_resize, which GLM inherits: snap each side to the nearest multiple offactor, then rescale by the area bound if the snapped canvas violates it.