Apply Ref Content
Keep the subject, skip the vibe
- model
- ref_latents
- MODEL
The name is refreshingly honest. Feed Apply Ref Content a reference image and it drags the content out of it - the subject, the pose, the composition - and into whatever you're generating, while leaving style to your text prompt. It's the ComfyUI answer to the "Reference" mode that A1111 users know from sd-webui-controlnet (the README calls it "Reference CNet"), and it gets there without a single downloaded model file.
Why you'd reach for it
This node ships in ComfyUI-RefSampling, a small proof-of-concept pack from logtd - the same person behind ComfyUI-Fluxtapoz and the ComfyUI port of InstanceDiffusion. The whole pack exists to try out attention-injection reference techniques, and Apply Ref Content is the "copy the subject" half of it. It slots into the model chain between your checkpoint and the KSampler. Think of it as the middle ground between img2img (which keeps layout but drifts the subject) and a trained adapter like IP-Adapter (which needs its own weights): this reuses the model's own attention, so it costs you no extra files and no training run.
How it works
Here's the trick that makes it model-file-free. During each denoising step inside the active percent window, the wrapped UNet noisifies your reference latent up to the same sigma, runs it through the network once in "write" mode, and stashes the self-attention states at every transformer block. Then it runs your actual generation in "read" mode with those stashed states concatenated into the attention context. Your generated image literally attends to the reference image's content. The "adapter" is your own model's attention, banked and replayed - which is why the pack installs with zero model downloads.
The inputs that matter
You'll touch four things:
- ref_latents (
LATENT) - the reference itself, VAEEncode'd from your LoadImage. Use the same checkpoint's VAE. - fidelity (default 0.5) - the strength of the transfer. Push toward 1 for strong adherence, drop it when the reference starts overpowering your prompt.
- attention_bound (default 1.0) - gates how deep into the network the injection reaches. A second, subtler strength dial.
- start_percent / end_percent (default 0→1) - the familiar sampling window from KSampler: when during denoising the reference acts.
The enabled toggle just removes the config cleanly when off, so you can A/B a run in one click. The single output is MODEL - wire it into the next apply node or straight into KSampler.
Install
# Easiest - ComfyUI Manager:
# Manager → Install Custom Nodes → search "ComfyUI-RefSampling" → Install → restart ComfyUI
# Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/logtd/ComfyUI-RefSampling
# restart ComfyUI
No requirements.txt, no pip install, no model files. It only needs a working SD 1.5 or SDXL setup.
Where people get burned
- The chain matters. ApplyRefUNetNode has to be applied to the model somewhere before this node, or Apply Ref Content silently does nothing - the config gets stored, but nothing ever reads it. The example workflow wires it as
Checkpoint → ApplyRefUNetNode → ApplyRefContentNode → ApplyRefStyleNode → KSampler. Follow that order. - SD 1.5/SDXL UNets only. It hunts for
BasicTransformerBlockattention, so on Flux-class DiT models there's no plumbing and no error - just no effect. - Resolution mismatch. VAEEncode at a size close to your generation latent. Feed it a wildly different resolution and the reference pass gets weird.
- It's slower, on purpose. The write+read double pass roughly doubles attention cost while the reference is active. Budget for it.
- It's a proof of concept. Expect to dial fidelity per image rather than finding one setting and forgetting it. When it lands, it's genuinely cool; when it doesn't, lower the fidelity before you blame the node.
If you just want the mainstream path, IP-Adapter is the battle-tested version of "use an image as a prompt." This node is for when you want the same idea with no extra weights - and for understanding what attention injection is actually doing under the hood.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| ref_latents | LATENT | — | |
| enabled | BOOLEAN | true | — |
| fidelity | FLOAT | 0.500–1 | — |
| attention_bound | FLOAT | 1.000–1 | — |
| start_percent | FLOAT | 0.000–1 | — |
| end_percent | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |