Nodes/RES4LYF/ClownStyle_Attn_UNet
ComfyUI Node Runs on cloud

ClownStyle_Attn_UNet

Style transfer at the attention level for SD1.5 and SDXL

By ClownsharkBatwing·Created 2 years ago·Updated 22 days ago· 1,222
ClownStyle_Attn_UNet
  • mask
  • blocks
  • blocks
modescattersort
apply_toself
block_typeinput
block_listall
block_weights1.0
q_proj0.00
k_proj0.00
v_proj0.00
out0.00
tile_h128
tile_w128
invert_maskfalse

The classic-U-Net counterpart to ClownStyle_Attn_MMDiT - same job, different architecture family. This one targets SD1.5, SDXL, Stable Cascade and other models that still run the traditional U-Net (as opposed to the MMDiT transformer designs behind Flux, SD3.5 and HiDream). Like its MMDiT sibling, you don't use it alone: chain it into ClownStyle_UNet's blocks input to push style matching into the attention math itself, deeper than that node's own proj_in/proj_out taps reach.

How it works

Classic U-Net blocks come in three flavors - the downsampling encoder stages (input), the bottleneck (middle), and the upsampling decoder stages (output) - and block_type lets you pick any combination of the three. Within whichever stages you target, this node taps the attention computation: q_proj/k_proj/v_proj are the query/key/value projections and out is the attention's output projection. There's no q_norm/k_norm here the way ClownStyle_Attn_MMDiT has - plain U-Net attention doesn't do that normalization step, so there's nothing to tap. Each float weight controls how hard the chosen mode (the style-matching algorithm - scattersort, AdaIN, WCT, and the rest of the family shared with ClownStyle_UNet) applies at that tap.

The inputs and outputs that matter

  • mode - which style-matching algorithm runs. See ClownStyle_UNet for what each one does.
  • apply_to (self / self,cross / cross) - self-attention is the image attending to itself (composition and texture); cross-attention is the image attending to your text conditioning. Most style bleed happens through self-attention, so that's usually the one worth trying first if you're not sure which to target.
  • block_type (input / middle / output, or any combination) - which U-Net stage(s) to hit.
  • block_list (default "all") and block_weights (default "1.0") - narrow to specific block indices, and weight the effect differently across whichever ones you pick.
  • The four float taps - q_proj, k_proj, v_proj, out - default to 0 (off). Turn on one or two at a time rather than all four together.
  • mask + invert_mask restrict the effect spatially; tile_h/tile_w only apply to the tiled_ modes.
  • blocks (optional in/out) - chains this node with other ClownStyle_* nodes, feeding ultimately into ClownStyle_UNet.

How to install it

Via ComfyUI Manager, search "RES4LYF". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

then restart.

Common issues & troubleshooting

Nothing happening at all usually means every weight float is still at its zero default. That's the expected off state, not a broken connection - turn one tap on before judging the effect.

cross not doing much when self clearly does something is normal, not broken. Self-attention carries most of the compositional and textural style information; cross-attention mostly governs how the image reads your prompt, so it's a subtler lever for this specific job.

Reach for this only after ClownStyle_UNet's own controls aren't enough. This is fine-grained, per-block tuning layered on top of a much simpler top-level node - start there, add this when you need more precision than proj_in/proj_out gives you.

CategoryRES4LYF/sampler_extensions

Inputs (14)

NameTypeDefaultDescription
modeCOMBOscattersort10 options: none, scattersort_dir, scattersort_dir2, scattersort, tiled_scattersort, AdaIN, +4
apply_toCOMBOself3 options: self, self,cross, cross
block_typeCOMBOinput7 options: input, middle, output, input,middle, input,output, middle,output, +1
block_listSTRINGall
block_weightsSTRING1.0
q_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
k_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
v_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
outFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
tile_hINT12816–10000Tile size for tiled modes. Lower values will transfer composition more effectively. Dimensions of image must be divisible by this value.
tile_wINT12816–10000Tile size for tiled modes. Lower values will transfer composition more effectively. Dimensions of image must be divisible by this value.
invert_maskBOOLEANfalse
maskoptMASK
blocksoptBLOCKS

Outputs (1)

NameTypeDescription
blocksBLOCKS