StyleAligned Sample Reference Latents ♾️Mixlab
Capture a reference's latents for style-matched batches
- reference_image
- positive
- negative
- model
- vae
- ref_latents
- noised_output
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.
denoiseat 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_latentswon't connect to a normal sampler. It's aSTEP_LATENTStype, 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
stepsreasonable 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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| reference_image | IMAGE | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| model | MODEL | — | |
| vae | VAE | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| denoise | FLOAT | 1.000–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| ref_latents | STEP_LATENTS | — |
| noised_output | LATENT | — |