Nodes/ComfyUI-Toggle-Pass/Ref Image Encode
ComfyUI Node

Ref Image Encode

One prompt, up to ten reference images — this node is the whole multi-ref encode pipeline

By electricty00·Created 4 months ago·Updated 4 months ago· 0
Ref Image Encode
  • clip
  • vae
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6
  • image7
  • image8
  • image9
  • image10
  • conditioning
  • latent
num_images1
prompt
instructionDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.
模型类型Flux2
匹配原图尺寸OFF
输出宽度1024
输出高度1024
图层数3

You've got a reference image - a character, a product shot, a scene - and you want to hand it to an edit model like Flux 2 Klein or Qwen-Image-Edit and get a modified version back. Normally that means a pile of nodes: a CLIP Encode with a vision-language model, a VAE Encode for the reference, and some glue to tell the model "look at these pictures while you read this prompt." Ref Image Encode collapses that whole block into one node. Feed it up to ten images and a single instruction, and it hands back the conditioning and the reference latent, ready for the KSampler.

It's the marquee node of the Toggle-Pass pack, and it's aimed squarely at the workflow that has basically taken over character consistency since late 2025: instruction editing rather than IP-Adapter or ControlNet scaffolding (the modidex KB frames exactly this shift). If you're building a "one reference, many edits" graph on a modern model, this is the node that does the plumbing for you.

How it works

Under the hood it does the two-encoder dance that edit models expect. Each reference image gets VAE-encoded into a latent (resized to your output size first), and those latents are attached to the conditioning as reference_latents - that's the "appearance" channel. The same images get downscaled to roughly 384×384 and passed to the CLIP tokenizer as images=, which is the "semantics" channel: the vision-language text encoder actually sees the picture while it reads your prompt. No manual <|vision_start|> tokens, the tokenizer inserts those itself.

A couple of settings matter here, and they're labeled in Chinese in the node UI:

  • 模型类型 (Model type): Flux2, Qwen Layered, or SD / SDXL. This decides the latent geometry - Flux2 uses /16 spatial scaling, SD/SDXL uses /8. Pick the one that matches the model you're actually sampling, or your latent shape won't line up.
  • 匹配原图尺寸 (Match source size): ON uses the actual image dimensions; OFF uses 输出宽度/输出高度 (output width/height).
  • 图层数 (Layer count): only appears in Qwen Layered mode, and it's the interesting one. That mode outputs a 5D layered latent of shape [1, 16, layers+1, h/8, w/8] which you wire straight into the KSampler's latent input - it replaces a dedicated EmptyQwenImageLayeredLatentImage node, saving you a node and a size-matching headache.

Inputs and outputs that matter

Required inputs: clip (a vision-language CLIP, see below), vae, num_images (1–10, this controls how many image1imageN slots appear), prompt, and instruction (the system prompt - the default is tuned for Qwen-Image-Edit-style models, so edit it if your model expects different framing).

Outputs: one conditioning and one latent. The conditioning goes to the KSampler's positive input; the latent is the reference latent from the first image, so for img2img-style editing you feed that to the sampler's latent input instead of an Empty Latent.

The gotcha that bites people

This node needs a CLIP that can actually take images - Qwen2.5-VL or the Qwen3-4B that ships with Flux 2 Klein. Hook up a plain SD CLIP and clip.tokenize(images=...) will fail. The README says it plainly: requires Qwen2.5-VL or compatible. And grow num_images before you wire things up - adding slots is safe, but shrinking removes slots from the top, so a wire on the last slot will get dropped.

Installing it

The whole pack installs as one:

cd ComfyUI/custom_nodes
git clone https://github.com/electricty00/ComfyUI-Toggle-Pass

then restart ComfyUI. Or use ComfyUI Manager and search for ComfyUI-Toggle-Pass. There's no requirements.txt - the only dependencies are the ones ComfyUI already ships (torch, PIL, numpy), so this is one of the rare custom nodes that can't break your environment. The pack is a small personal project with essentially no community footprint yet, so expect the polish of a node built for its author's own workflows rather than a big open-source project.

CategoryToggle-Pass

Inputs (20)

NameTypeDefaultDescription
clipCLIP
vaeVAE
num_imagesINT11–10
promptSTRING
instructionSTRINGDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE
image6optIMAGE
image7optIMAGE
image8optIMAGE
image9optIMAGE
image10optIMAGE
模型类型optCOMBOFlux23 options: Flux2, Qwen Layered, SD / SDXL
匹配原图尺寸optCOMBOOFF2 options: OFF, ON
输出宽度optINT1024256–4096
输出高度optINT1024256–4096
图层数optINT31–64

Outputs (2)

NameTypeDescription
conditioningCONDITIONING
latentLATENT