Nodes/yiu_comfy_nodes/🔁 Upscale Loop START
ComfyUI Node

🔁 Upscale Loop START

Upscale to 10,000px without one giant, artifact-riddled jump

By leizingyiu·Created about a year ago·Updated 3 months ago· 1
🔁 Upscale Loop START
  • image
  • yiu_upscale_loop_flow
  • image
  • scale_this_time
  • loop_state
  • print(step_index)
  • print(step_total)
  • image_last_step
  • help_text
target_width0
target_height0
scale_every_time2.000
max_tile_size1024
min_tile_overlap_px64
tile_overlap_ratio0.10

The README's third use case for this pack is the reason the upscale loop exists: take an image to 10,000+ pixels for print. Do that in one 6x upscale and you'll eat your VRAM, hit the model's sensible limits, and often get mush. The fix the community settled on ages ago is the same one this node formalizes - tiled diffusion upscaling: split the image, upscale the pieces, stitch them back. And the refinement this pack adds is to do it in multiple small steps (1.3–1.8x each) so no single pass overreaches.

yiuUpscaleLoopStart is the entry point of a two-node loop. You clamp any upscaler of your choice between START and END, and the pair handles the step math, the tiling, and the loop bookkeeping. You bring your own upscaler - this pack doesn't ship one - which is the whole point: it works with an ESRGAN model node, a SeedVR2 node, an SD img2img pass, whatever.

How it works

START is a smart divider. It computes the total scale you need (max(target_w / w, target_h / h)), then splits it into steps with scale_every_time as the per-step factor, using ceil(log(total) / log(step)) to count them. Every step gets scale_every_time as its scale_this_time - except the last one, which gets an auto-computed catch-up factor so the cumulative result lands exactly on your target instead of overshooting. Then it tiles the current image into a batch of overlapping tiles (that's the tiling_meta/image_tile machinery) and hands you the batch, the scale, and a loop state object.

Each loop iteration feeds the previous iteration's output back in: your upscaler gets the new tiles, and START recomputes for the next step. It stops when the step counter hits the total.

The inputs that matter

  • image - the image to upscale.
  • target_width / target_height - set both, or set one and leave the other at 0 and the aspect ratio is preserved.
  • scale_every_time - the per-step factor (default 2.0). The author's own notes recommend 1.2–2.0; smaller steps are gentler on quality.
  • max_tile_size - tile edge length (default 1024). Set to 0 to disable tiling and process the whole image per step.
  • min_tile_overlap_px (default 64) and tile_overlap_ratio (default 0.1) - control the seam width; the effective overlap is the max of the two rules.

Outputs

  • yiu_upscale_loop_flow → must connect to END.flow (this wire drives the loop).
  • image → the tile batch, into your upscaler's image input.
  • scale_this_time → into your upscaler's scale/upscale_by input (ignore it if your upscaler uses a fixed factor).
  • loop_state → must connect to END.loop_state.
  • print(step_index) / print(step_total) → current step and total, handy for filenames or a progress display.
  • image_last_step → the full image as of the previous round, useful for a save-every-step node.

Installing it

Part of yiu_comfy_nodes by leizingyiu. ComfyUI Manager → search yiu_comfy_nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/leizingyiu/yiu_comfy_nodes

Restart after. No model downloads - the upscaler is yours.

Where people get burned

  • The loop doesn't run without both wires. flow and loop_state must connect START → END, or the loop can't recurse and the graph hangs or produces garbage. This is the #1 mistake.
  • It needs a recent ComfyUI. The loop runs on ComfyUI's dynamic graph expansion (GraphBuilder); on an old install it raises a "GraphBuilder is not available" error. Update.
  • Tiling off by default is on. max_tile_size defaults to 1024, so you are tiling. If you don't want tiles (small targets), set it to 0.
  • Scale every time too big. At the default 2.0 you're already near the quality edge for ESRGAN-type upscalers; if you see artifacts, drop toward 1.5 and let the loop take more steps.
  • Big outputs break previews. Over ~200 megapixels, ComfyUI's preview nodes may refuse to display the result. The pack ships a toast warning about this; save with a Save node instead of previewing.
Categoryyiu_nodes

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
target_widthINT00–9999999
target_heightINT00–9999999
scale_every_timeFLOAT2.0001.001–16
max_tile_sizeINT102448–9999999
min_tile_overlap_pxINT640–9999999
tile_overlap_ratioFLOAT0.100–1

Outputs (8)

NameTypeDescription
yiu_upscale_loop_flowFLOW_CONTROL
imageIMAGE
scale_this_timeFLOAT
loop_stateYIU_UPSCALE_LOOP_STATE
print(step_index)INT
print(step_total)INT
image_last_stepIMAGE
help_textSTRING