ContextRef TuneβAttn+Adain ππ π
Attention injection plus color and style matching
- CONTEXTREF_TUNE
This is ContextRef Tune Β· Attn's three attention dials, plus a second consistency mechanism stacked on top: AdaIN, Adaptive Instance Normalization, a standard style-transfer technique that matches the statistical "feel" - in practice, color, contrast, and luminance - of one image's features onto another's. Here it's applied between the reference context window and every later window, on top of the attention injection ContextRef already does.
What it does
Six optional float inputs, all 0β1, all defaulting to 1. The first three are identical to the plain Tune Β· Attn node:
attn_style_fidelity,attn_ref_weight,attn_strength- the attention-injection dials, same behavior as Tune Β· Attn.
The three new ones control the added AdaIN layer:
adain_style_fidelity- how strongly the reference's color and lighting statistics get matched onto later windows.adain_ref_weight- how much weight the reference's statistics carry relative to each window's own, when blended.adain_strength- an overall multiplier on the AdaIN effect.
Output is CONTEXTREF_TUNE, same as Tune Β· Attn, wired the same way into contextref_tune or tune_replace.
Why add AdaIN on top of attention
Attention injection alone pulls identity and composition toward the reference; it doesn't necessarily lock color and exposure the same way. Stacking AdaIN on top adds that statistical color and lighting match, which is the more direct fix if what's actually drifting across your sliding-context render is tone and grading rather than who's in the frame. The tradeoff is the standard one with AdaIN-style matching in general: push it hard enough and you can flatten out lighting variation you actually wanted - a scene that's supposed to dim or shift color over the course of the clip instead gets pulled back toward the reference window's exposure the whole way through.
Where this fits relative to Tune Β· Attn
Everything in the plain Tune Β· Attn node's article carries over here unchanged - the three attn_* dials behave identically. This node exists purely to add the adain_* layer on top, for renders where attention injection alone isn't enough to hold color and lighting steady across a long sliding-context render.
Installing it
ComfyUI Manager: search AnimateDiff Evolved, author Kosinkadink, install, restart. Or clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved into custom_nodes manually and restart.
A reasonable way to tune it
Since there's essentially no community writeup to lean on here, treat the two halves separately rather than adjusting all six at once: get the attention dials to a level of identity-consistency you're happy with first, using a short test render, then add the AdaIN dials on top only if color and lighting are still the specific thing drifting. Pushing both effects to full strength simultaneously makes it hard to tell which one is responsible when a render looks over-locked.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| attn_style_fidelityopt | FLOAT | 1.000β1 | β |
| attn_ref_weightopt | FLOAT | 1.000β1 | β |
| attn_strengthopt | FLOAT | 1.000β1 | β |
| adain_style_fidelityopt | FLOAT | 1.000β1 | β |
| adain_ref_weightopt | FLOAT | 1.000β1 | β |
| adain_strengthopt | FLOAT | 1.000β1 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CONTEXTREF_TUNE | CONTEXTREF_TUNE | β |