ComfyUI Node

Resize Image

Prepping content/style images for ComfyUI-Attention-Distillation

By zichongc·Created about a year ago·Updated about a year ago· 110
Resize Image
  • image
  • image
resolution512

This is the small, unglamorous utility node that's easy to skip past - but if you're doing style transfer or style-specific generation with ComfyUI-Attention-Distillation, don't. It takes an image and a target resolution and hands back the resized image, and it exists specifically because the nodes downstream (ADOptimizer, ADSampler) both take explicit height/width parameters of their own. Feed them a content or style image that's a wildly different size than what you told the sampler to generate, and you're asking for trouble you didn't need to have.

What it's for

Attention Distillation works by optimizing attention features so that the visual character of one image (style) gets transferred onto another (content), or steers a fresh text-to-image generation. That kind of feature matching wants your reference images normalized to a sensible, consistent size - not full-resolution uploads with mismatched aspect ratios. Resize Image is the pack's answer: drop your Load PIL Image output through this before it reaches ADOptimizer or ADSampler, matched to the height/width you've set on whichever of those you're using.

It's a genuinely simple node with no magic - one input image, one target number, one resized image out. There's nothing to overthink here beyond picking a sane resolution.

The inputs and output

  • image - the IMAGE to resize, typically straight from Load PIL Image.
  • resolution - an integer, default 512, adjustable from 256 up to 4096 in steps of 8. That step size isn't arbitrary: SD-family VAEs downsample 8x, so working dimensions divisible by 8 avoid rounding artifacts at the latent boundary.

Output is IMAGE - wire it into ADOptimizer's content/style, or ADSampler's style.

For what value to actually pick: match the base model. 512 is the sweet spot for SD1.5 (what this pack was originally built and tested around); push higher if you've loaded SDXL or Flux through Load Distiller, since those models were trained at larger native resolutions and tend to underperform when forced down to SD1.5-era sizes.

Installing it

Ships with the whole pack, no separate install path.

ComfyUI Manager - search "ComfyUI-Attention-Distillation" and install.

Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/zichongc/ComfyUI-Attention-Distillation
cd ComfyUI-Attention-Distillation
pip install -r requirements.txt

Restart ComfyUI. This node alone has no model dependency, but you'll need Load Distiller's diffusers-format model set up for anything you actually plug its output into.

Common issues

Picking a resolution that doesn't match your base model. This node will happily resize to any value in range - it won't stop you from generating at 512 with SDXL loaded, or blowing SD1.5 up to 4096. The node isn't the guardrail; matching resolution to the model you loaded in Load Distiller is on you.

VRAM climbing fast at higher resolutions. Both ADOptimizer and ADSampler are optimization-based - they backpropagate through attention layers over many steps (up to 500 for style transfer), which holds a lot more in memory than a normal single forward-pass sampler at the same resolution. If you're pushing this node's resolution toward the high end and hitting out-of-memory errors, that's the mechanism, not a bug - dial the resolution back before you dial back steps.

Dependency conflicts on install. Like the rest of this pack, that's a requirements.txt/shared-Python-environment issue (diffusers version clashing with another installed node pack), not something specific to this node.

CategoryAttentionDistillationWrapper

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
resolutionINT512256–4096

Outputs (1)

NameTypeDescription
imageIMAGE