π Apply Reference
Apply Kontext Reference (SDVN)
- conditioning
- vae
- image
- image2
- image3
- mask
- conditioning
- width
- height
- latent
This node feeds reference images into your conditioning for Flux Kontext-style editing. Kontext's whole trick is that it takes a picture and an instruction and re-emits the picture with the change applied - "put this jacket on her," "swap the background," "remove the watermark" - and the way it consumes the reference is by pulling it into the conditioning rather than through a separate adapter. Apply Kontext Reference is the node that does that pulling-in: it takes conditioning you've already encoded from a text prompt, attaches up to three reference images to it, and hands back the combined conditioning plus a matching latent.
The mechanism shows in the I/O. You give it a conditioning (your encoded instruction), a vae, and one to three images (image, image2, image3), and it VAE-encodes those references and concatenates them onto the conditioning as reference latents - the in-context editing recipe. img_size controls the resolution the references get worked at, which is not a cosmetic setting: Kontext and its cousins are sensitive to input size, and an uncontrolled reference resolution is a classic cause of edits that come out geometrically offset or with skewed proportions. There's an optional mask for localizing where the reference applies. The outputs are the enriched conditioning, its width and height, and a latent - you run the conditioning and latent through your Kontext sampler.
The three-image support is the reason to like it. Single-reference editing is the common case, but a lot of the interesting Kontext work is compositional - this subject plus this product, this person in this scene - and having three reference slots in one node lets you set that up without chaining. Feed it a character, a garment, and a setting and let the model reason about combining them.
Two honest limits, both inherited from the model rather than the node. First, licensing: Flux Kontext Dev ships under a non-commercial license, and its mid-2025 anti-circumvention clause specifically made NSFW LoRAs a violation - platforms ran takedown waves over it. If your work is either commercial or NSFW, Kontext is the wrong base and the community answer is Qwen-Image-Edit, which is Apache 2.0 with no content terms. Second, the failure mode of the whole editor category: these models re-emit the entire frame, so pixels you didn't touch drift a little and faces are the first thing to wander over a chain of edits. That's why heavy workflows still mask the region and stitch the edit back rather than trusting a clean full-frame pass. This node sets up the reference; it can't fix the model's tendency to nudge everything else.
Install comes with the pack. ComfyUI Manager, search SDVN_Comfy_node; or cd ComfyUI/custom_nodes && git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node, then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from your ComfyUI root and restart. The node is glue - you supply the Kontext model, its CLIP/text encoder, and the VAE separately, the same as any Flux edit graph.
Troubleshooting. If the edit comes out shifted or distorted, control img_size - matching the reference resolution to what the model wants is the single biggest fix, the same input-size lesson the whole editor family teaches. Garbled output usually means a VAE that doesn't match the model, since the references are VAE-encoded here. And if the reference seems ignored, confirm an image is actually plugged into one of the three slots and that your conditioning came from the right Kontext text encoder - feeding it a plain SDXL conditioning won't behave, because this is built for the in-context editing path, not classic text-to-image.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| img_size | INT | 00β4096 | β |
| conditioning | CONDITIONING | β | |
| vae | VAE | β | |
| imageopt | IMAGE | β | |
| image2opt | IMAGE | β | |
| image3opt | IMAGE | β | |
| maskopt | MASK | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| conditioning | CONDITIONING | β |
| width | INT | β |
| height | INT | β |
| latent | LATENT | β |