Nodes/VLM_nodes/VLM Image Pixel Budget
ComfyUI Node Runs on cloud

VLM Image Pixel Budget

Your VLM doesn't need 4K. It needs your answer.

By gokayfem·Created 3 years ago·Updated 9 days ago· 583
VLM Image Pixel Budget
  • images
  • optimized_images
  • width
  • height
  • optimization_report
max_megapixels1.00
max_edge1344
multiple14
resize_qualityFast (area)

Every vision model you feed a huge image does the same wasteful thing: it chops it into hundreds of visual tokens and processes all of them, even though the answer was in the first fifty. VLM Image Pixel Budget is the one-node fix - it shrinks your analysis copy to a sane size exactly once, before any VLM sees it, so you're not paying the full-res tax over and over.

It belongs to the pack's performance layer, which is deliberately model-agnostic: the savings apply whether your VLM runs on CUDA, ROCm, Metal, XPU, or a hosted API. The pack's recommended chain is Video SliceVLM Adaptive Frame Samplerthis node → any VLM.

How it works

The math, from the source: it computes a single scale factor that respects all three of your constraints - never exceed max_megapixels, never exceed max_edge, and never upscale (scale is capped at 1.0). Then it floors the result to a multiple of 14 or 28 (common VLM vision-patch sizes) or 32 (a common detector backbone stride), or leaves dimensions arbitrary with multiple=1. It resizes with fast area interpolation or antialiased bicubic depending on resize_quality, and it does it once - downstream models get the same optimized copy instead of each one re-downscaling the original.

It also gives you the receipt: optimization_report tells you the input/output dimensions and the exact visual-work reduction factor.

Inputs and outputs that matter

  • images (IMAGE) - any still image or video frame batch.
  • max_megapixels - the budget, default 1.0. This is the knob that controls token cost.
  • max_edge - longest-side cap, default 1344.
  • multiple - dimension alignment; leave at 14 unless you know your model wants 28 or 32.
  • resize_quality - Fast (area) for most work, Quality (bicubic) when edge fidelity matters.

Outputs: optimized_images, width, height, and optimization_report.

Installing this pack

Same one-pack install as everything else here. ComfyUI Manager: search VLM_nodes. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/gokayfem/ComfyUI_VLM_nodes
cd ComfyUI_VLM_nodes
python -m pip install -r requirements.txt

ComfyUI's Python for pip. This node downloads nothing - it's pure torch resize.

Common issues

The one thing to keep straight: this changes the resolution of the analysis copy, which means detection coordinates produced downstream live in this node's output space. That's fine as long as you're consistent about which image your boxes describe - the pack's own docs warn that a model's official processor still does its own required normalization and cropping afterward. And don't expect it to be the whole story on speed: the README is explicit that this cuts the input workload (11.38× on their test clip) but token generation and the model's vision encoder still set your end-to-end time.

CategoryVLM Nodes/Performance

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
max_megapixelsFLOAT1.000.01–64
max_edgeINT134432–16384
multipleCOMBO1414/28 suit common VLM vision patches; 32 suits many detector backbones. Use 1 for arbitrary sizes.
resize_qualityCOMBOFast (area)2 options: Fast (area), Quality (bicubic)

Outputs (4)

NameTypeDescription
optimized_imagesIMAGE
widthINT
heightINT
optimization_reportSTRING