Nodes/comfyui-mixlab-nodes/StyleAligned Sample Reference Latents ♾️Mixlab
ComfyUI Node Runs on cloud

StyleAligned Sample Reference Latents ♾️Mixlab

Capture a reference's latents for style-matched batches

By MixLabPro·Created 3 years ago·Updated 2 months ago· 1,859
StyleAligned Sample Reference Latents ♾️Mixlab
  • reference_image
  • positive
  • negative
  • model
  • vae
  • ref_latents
  • noised_output
seed0
steps20
cfg8.0
scheduler
denoise1.00

This is the setup step for StyleAligned - a training-free trick for making a whole batch of images share one consistent style. You give it a reference image, it runs that image back through the diffusion process to capture the latents at each denoising step, and those captured latents become the anchor that a downstream StyleAligned sampler uses to keep every generation on-style. Mixlab ports this from Google's StyleAligned research (by way of style_aligned_comfy).

The idea behind it

StyleAligned's insight is that you can enforce a shared look across a batch by sharing attention. During generation, each image "looks at" the reference through the model's self-attention, so they all inherit its palette, texture, and rendering - without any LoRA training or fine-tuning. But to do that, the pipeline first needs the reference expressed in the model's own terms: its latent trajectory through the denoising steps. That's this node's job - it samples the reference and records those per-step latents.

Because it's a prep/analysis step, it's a bit heavier than a plain loader - it runs a real sampling pass over the reference. Think of it as encoding your style anchor once, up front, so the actual batch can lean on it.

The inputs that matter

Most of these are the familiar sampler controls, applied to the reference:

  • reference_image - the image whose style you want to propagate. This is the whole point.
  • model / vae - the diffusion model and VAE to sample and decode with. Use the same model you'll generate the batch on, or the latents won't mean the same thing.
  • positive / negative - conditioning for the reference pass.
  • steps, cfg, scheduler, denoise, seed - standard sampling parameters. denoise at 1.0 samples the reference fully; the scheduler list is the usual ComfyUI set (karras, simple, exponential, and so on).

Outputs: ref_latents (type STEP_LATENTS - the captured per-step trajectory, the thing the StyleAligned apply/sampler node consumes) and noised_output (a LATENT you can inspect or decode).

Installing it

Get the pack via ComfyUI Manager (search mixlab, install comfyui-mixlab-nodes, restart), or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/shadowcz007/comfyui-mixlab-nodes

then install requirements and restart. No dedicated model download - it uses your existing checkpoint and VAE.

Common snags

  • ref_latents won't connect to a normal sampler. It's a STEP_LATENTS type, custom to StyleAligned - it only plugs into the matching StyleAligned node that applies the shared attention. This node alone doesn't produce your final images; it feeds the one that does.
  • Style doesn't transfer. Make sure the reference pass uses the same model as your batch. Mismatched checkpoints mean the captured latents describe a different space than the one you're generating in.
  • It's slower than expected. It's running an actual sampling pass, not just loading a file. That's inherent - keep steps reasonable for the reference; you don't need 100 to capture a style anchor.
  • Fair expectation-setting: StyleAligned is a soft consistency trick. It nudges a batch toward a shared look, it doesn't clone the reference. For hard character or identity consistency you'd want IPAdapter, a LoRA, or a reference-conditioned model instead.
Category♾️Mixlab/Style

Inputs (10)

NameTypeDefaultDescription
reference_imageIMAGE
positiveCONDITIONING
negativeCONDITIONING
modelMODEL
vaeVAE
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
denoiseFLOAT1.000–1

Outputs (2)

NameTypeDescription
ref_latentsSTEP_LATENTS
noised_outputLATENT