Image Upscale With Model Batched
Model upscaling that won't OOM on a batch
- upscale_model
- images
- IMAGE
If you've ever tried to run a whole batch of frames - or a big pile of images - through the native UpscaleImageWithModel node and watched ComfyUI fall over with an out-of-memory error, this is the fix. Same ESRGAN-style model upscaling, but it processes the batch in sub-batches so peak VRAM stays sane, with an optional downscale on the way out. It's a small, practical quality-of-life swap that turns "can't do it" into "done."
What it does differently
Model-based upscalers (the 4x-UltraSharp, RealESRGAN, SwinIR family of .pth files you load with an upscale-model loader) run a neural net over the image to add detail as they enlarge. That's memory-hungry, and the native node tries to process the entire batch at once. Feed it 60 video frames and it wants to hold all 60 upscaled results - and their intermediate tensors - in VRAM simultaneously. Boom.
This node's node-description says it plainly: "Same as ComfyUI native model upscaling node, but allows setting sub-batches for reduced VRAM usage. Optionally downscale the result with a ratio." So it chunks the batch, upscales each chunk, frees the memory, moves on. Slower wall-clock, but it actually finishes on a card that couldn't otherwise. For upscaling video frame sequences this is the one you want.
The inputs that matter
upscale_model- the loaded upscale model (from an upscale-model loader), same as the native node.images- the batch to upscale.per_batch(default 16) - the key knob. How many images to process at a time. Lower it if you're still OOMing; raise it for a bit more speed if you've got headroom. This is the dial that trades memory for throughput.downscale_ratio(optional, default 1) - most upscale models are fixed 4x. If you wanted, say, 2x, you upscale 4x then set this below 1 to pull the result back down. A ratio of 1 means no downscale.downscale_method(defaultlanczos) - the resampling filter for that downscale; lanczos is the sharp, sensible default.precision(defaultfloat32) - drop tofloat16/bfloat16to shave VRAM further if float32 is tight, at a small quality risk.
The output is the upscaled IMAGE batch.
How to install it
It's in kijai's KJNodes pack.
- ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, thenpip install -r ComfyUI-KJNodes/requirements.txt, restart.
The node has no model of its own - you supply the upscale .pth. Grab those from the OpenModelDB catalog or wherever you get your ESRGAN models and drop them in models/upscale_models.
Common issues & troubleshooting
Still running out of memory. Lower per_batch - 8, 4, even 1 if you have to. At per_batch 1 it upscales one image at a time, which is the safest and slowest. Also try dropping precision to float16. If a single image at the model's native scale still won't fit, the image itself is too large for tiled-free upscaling and you need a tiled upscaler instead.
It's slow. That's the trade - sub-batching serializes work that the native node did all at once (when it fit). If you have the VRAM headroom, raise per_batch to claw some speed back.
Video frames flicker after upscaling. Model upscalers work per-frame with no temporal awareness, so tiny per-frame differences show up as shimmer. That's inherent to frame-by-frame upscaling, not this node specifically - dedicated video upscalers handle temporal consistency, at their own cost.
The output isn't the size you expected. Remember the model dictates the scale (usually 4x). If you wanted a different final size, that's what downscale_ratio is for - upscale at the model's native factor, then ratio back down to your target.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| upscale_model | UPSCALE_MODEL | — | |
| images | IMAGE | — | |
| per_batch | INT | 161–4096 | — |
| downscale_ratioopt | FLOAT | 1.000.01–1 | — |
| downscale_methodopt | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| precisionopt | COMBO | float32 | 3 options: float32, float16, bfloat16 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |