Nodes/ComfyUI_experiments/ReferenceOnlySimple
ComfyUI Node

ReferenceOnlySimple

Reference-only in one node

By comfyanonymous·Created 3 years ago·Updated 2 years ago· 202
ReferenceOnlySimple
  • model
  • reference
  • MODEL
  • LATENT
batch_size1

You feed it one image, and suddenly everything you generate comes out looking like it - same composition, same subject, same vibe. No ControlNet checkpoint, no LoRA, no training. That's reference-only control, and this is the node that put it in ComfyUI.

The trick was famous in the SD 1.5 days as "reference-only ControlNet": a ControlNet preprocessor that isn't a ControlNet at all. It has no conditioning image to extract spatial features from, so it does something sneakier - it injects the reference image's self-attention features straight into the denoiser. Every image you generate ends up "looking at" the reference, which is why style, pose, and composition transfer so well. The mechanism is exactly the "self-attention injection" that later got absorbed into ComfyUI core, and this simple version from comfyanonymous's experiments pack is the original.

How it works

Open the source and it's ~30 lines. The node clones your model and patches the self-attention layers (attn1). It takes your reference latent plus batch_size blank latents, concatenates them into one batch, and rewrites the keys/values of the blank slots so they borrow the reference's own self-attention content. Result: the whole batch attends to the reference image on every denoising step.

That's the whole "control". It's why reference-only is so good at style transfer and so bad at precise identity - it steals the way pixels relate to each other, not the pixels themselves. For faces and characters, IP-Adapter and the recognition-based adapters took over this job; reference-only remains a legit, zero-extra-download option for a general look.

The inputs that matter

Three inputs, all required:

  • model - your checkpoint's MODEL, straight from the loader.
  • reference - a LATENT. VAE-encode your reference image (Load Image → VAEEncode) and feed it here.
  • batch_size - INT, 1 to 64, default 1. How many generated images share the reference in one pass.

Outputs are MODEL and LATENT, and here's where people get burned: you must wire both into the sampler. The MODEL output goes to KSampler's model, and the LATENT output - not the reference latent you fed in - goes to KSampler's latent_image. The pack ships an example workflow (workflows/reference_only_simple.json) showing exactly that: loader → model in, LoadImage → VAEEncode → reference, then both node outputs into KSampler. If you forget the LATENT output, the sampler sees nothing to denoise and you get noise or an error.

Installing it

The README's own instructions are refreshingly low-tech: copy the .py files into your custom_nodes directory. The easy way is ComfyUI Manager - search for ComfyUI_experiments. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/comfyanonymous/ComfyUI_experiments

Restart ComfyUI. There's no requirements.txt and nothing to download - this pack is pure Python on top of what ComfyUI already ships. The node appears under the custom_node_experiments category.

Troubleshooting

  • Black or garbage output - you wired the original reference latent into the sampler instead of the node's LATENT output. Check that wire first.
  • Wrong batch behavior - batch_size is how many generated images attend to the reference, not how many reference images you can stack.
  • Face drifts - expected. Reference-only is a style/composition transfer, not identity preservation. If you need a specific face to survive, that's IP-Adapter/FaceID territory (and on 2026 models, an edit model's job).
  • Name collision - if you run an older ComfyUI that still bundles ReferenceOnlySimple in core, the pack's version shadows it. They're the same thing, so you lose nothing.

It's a small, sharp tool and a genuine slice of ComfyUI history. For style transfer on SD 1.5 or SDXL it still works perfectly, and now you know exactly what it's doing.

Categorycustom_node_experiments

Inputs (3)

NameTypeDefaultDescription
modelMODEL
referenceLATENT
batch_sizeINT11–64

Outputs (2)

NameTypeDescription
MODELMODEL
LATENTLATENT