Nodes/RES4LYF/ClownGuide AttnInj (HiDream)
ComfyUI Node Runs on cloud

ClownGuide AttnInj (HiDream)

Style transfer through attention injection

By ClownsharkBatwing·Created 2 years ago·Updated 18 days ago· 1,222
ClownGuide AttnInj (HiDream)
  • guide
  • mask
  • weights
  • guides
  • guides
weight1.00
weight_schedulerconstant
double_blocks0,1,3
double_weights1.0
single_blocks20
single_weights0.5
img_q0.00
img_k0.00
img_v1.00
txt_q0.00
txt_k0.00
txt_v0.00
img_q_norm0.00
img_k_norm0.00
img_v_norm0.00
txt_q_norm0.00
txt_k_norm0.00
txt_v_norm0.00
start_step0
end_step15
invert_maskfalse

AttnInj is the heavier-handed sibling of the AdaIN style guide. Instead of matching a reference's feature statistics, it reaches into the model's attention and injects the reference's queries, keys, and values directly. That's a stronger, more structural way to transfer a look - it can carry over not just color and tone but the way forms and edges are put together. It targets MMDiT models, HiDream especially.

Same guide framework as the rest of the pack: this node doesn't produce an image, it builds a GUIDES bundle that plugs into the sampler's guides input and steers denoising toward a reference during sampling. Guides chain - you can stack this after other guides via the guides passthrough - and the sampler applies the whole stack. AttnInj is the "get in there and rewrite attention" link.

How it works

Attention inside a transformer is built from three projections: query (Q), key (K), and value (V). This node takes those from your reference (the guide latent) at selected blocks and blends them into the generation's attention, on the image side and/or the text side. Value injection is the default emphasis - img_v starts at 1 while the query and key weights start at 0 - because V tends to carry "what the content looks like" while Q and K govern "what attends to what," so leaning on V transfers appearance with fewer structural surprises. The per-projection norm controls exist for finer shaping.

The inputs and outputs that matter

You will not touch most of the two dozen parameters. The ones that matter:

  • guide (LATENT, optional) - the reference to inject from. The point of the node.
  • weight (FLOAT, default 1) - overall injection strength.
  • img_v / img_q / img_k and the txt_* equivalents (FLOAT) - how much of each projection to inject on the image and text streams. Defaults lean on img_v; nudge these before anything else if you want more or less transfer.
  • double_blocks / single_blocks (STRING) - which transformer blocks to inject at (defaults: double 0,1,3, single 20).
  • weight_scheduler, start_step / end_step, mask / invert_mask - the standard guide scheduling, step window, and regional controls shared across the family.

Output is a guides (GUIDES) bundle for the next guide or the sampler.

How to install it

ComfyUI Manager: search RES4LYF, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/ClownsharkBatwing/RES4LYF/, pip install -r requirements.txt in the venv (portable: embedded python's pip), restart, hard-refresh F5. Load a HiDream (or other supported MMDiT) checkpoint. Nested sampler menu wants rgthree-comfy with "Auto Nest Subdirectories" on.

Common issues

Attention injection is powerful and therefore easy to overdo. Push the weights too high and the reference stops being an influence and starts being the output - you'll get the source image's structure bleeding through your prompt, sometimes as ghosting or doubled forms. If the result looks like a bad double-exposure, back the img_*/txt_* weights down.

Because there are so many dials, resist the urge to move several at once. The whole pack suffers from thin documentation and "it depends on the image" is the real answer to most settings questions, so a fixed seed and one-variable-at-a-time is the only sane way to learn what each projection does. And the shared scheduler warning applies: bong_tangent ignores the workflow's shift and runs its own, so if scheduling seems off, switch to beta57 or constant. If you only need a light stylistic nudge, the AdaIN guide is easier to control - reach for AttnInj when you specifically want strong, structural transfer.

CategoryRES4LYF/sampler_extensions

Inputs (25)

NameTypeDefaultDescription
weightFLOAT1.00-100–100Set the strength of the guide by multiplying all other weights by this value.
weight_schedulerCOMBOconstant12 options: constant, simple, sgm_uniform, karras, exponential, ddim_uniform, +6
double_blocksSTRING0,1,3
double_weightsSTRING1.0
single_blocksSTRING20
single_weightsSTRING0.5
img_qFLOAT0.00-100–100Set relative injection strength.
img_kFLOAT0.00-100–100Set relative injection strength.
img_vFLOAT1.00-100–100Set relative injection strength.
txt_qFLOAT0.00-100–100Set relative injection strength.
txt_kFLOAT0.00-100–100Set relative injection strength.
txt_vFLOAT0.00-100–100Set relative injection strength.
img_q_normFLOAT0.00-100–100Set relative injection strength.
img_k_normFLOAT0.00-100–100Set relative injection strength.
img_v_normFLOAT0.00-100–100Set relative injection strength.
txt_q_normFLOAT0.00-100–100Set relative injection strength.
txt_k_normFLOAT0.00-100–100Set relative injection strength.
txt_v_normFLOAT0.00-100–100Set relative injection strength.
start_stepINT00–10000
end_stepINT15-1–10000
invert_maskBOOLEANfalse
guideoptLATENT
maskoptMASK
weightsoptSIGMAS
guidesoptGUIDES

Outputs (1)

NameTypeDescription
guidesGUIDES