Nodes/RES4LYF/ClownStyle_TransformerBlock_UNet
ComfyUI Node Runs on cloud

ClownStyle_TransformerBlock_UNet

The finest-grained style-transfer dial RES4LYF has

By ClownsharkBatwing·Created 2 years ago·Updated 21 days ago· 1,222
ClownStyle_TransformerBlock_UNet
  • mask
  • blocks
  • blocks
modescattersort
block_typeinput
block_listall
block_weights1.0
norm10.00
norm20.00
norm30.00
self_attn0.00
cross_attn0.00
ff0.00
self_attn_res0.00
cross_attn_res0.00
ff_res0.00
tile_h128
tile_w128
invert_maskfalse

This is the deepest control point in RES4LYF's U-Net style-transfer stack - one rung past ClownStyle_SpatialBlock_UNet, targeting a single transformer block inside the spatial-transformer submodule directly. If ClownStyle_Block_UNet is "turn style transfer up on this whole stage" and ClownStyle_SpatialBlock_UNet is "turn it up on the attention submodule specifically," this node is "turn it up on exactly the self-attention, or exactly the cross-attention, or exactly the feedforward, inside that submodule." Chains into ClownStyle_UNet's blocks input the same way as the rest of the family.

How it works

Every attention block in classic Stable Diffusion / SDXL U-Nets follows the same three-sublayer shape: self-attention (the image attending to itself), then cross-attention (the image attending to your text conditioning), then a feedforward layer - each preceded by its own normalization and each with its own residual connection back into the stream. This node exposes all nine of those pieces individually: norm1/self_attn/self_attn_res for the self-attention sublayer, norm2/cross_attn/cross_attn_res for cross-attention, and norm3/ff/ff_res for feedforward. Every one is a float weight, default 0, for how hard the chosen mode applies at that exact point.

The inputs and outputs that matter

  • mode - the style-matching algorithm (scattersort, AdaIN, WCT, and the rest - same set as ClownStyle_UNet).
  • block_type (input / middle / output, or combinations) - which U-Net stage(s) to target.
  • block_list (default "all") / block_weights (default "1.0") - narrow to and weight specific block indices.
  • self_attn / cross_attn / ff - the three main operation taps. If you only turn on one thing here, start with self_attn - it's where most style-related information (texture, composition, color) tends to live, versus cross_attn which is more about how the image reads your prompt.
  • norm1 / norm2 / norm3 and self_attn_res / cross_attn_res / ff_res - the normalization and residual taps for each of the three sublayers, for when the main operation taps alone aren't giving you the precision you want.
  • mask + invert_mask restrict spatially; tile_h/tile_w apply only to tiled_ modes.
  • blocks (optional in/out) chains this into the rest of the ClownStyle_* family, 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

Nine taps at zero by default - turn on self_attn alone first and see what it does before adding anything else. This is the most granular node in the family; stacking multiple taps at once makes it very hard to tell which one is responsible for what you're seeing.

If you find yourself here without having tried the coarser nodes first, back up. ClownStyle_UNet's own proj_in/proj_out, then ClownStyle_Block_UNet's spatial tap, then ClownStyle_SpatialBlock_UNet, are each a smaller search space - most workflows don't need to come all the way down here, and it's a lot easier to reason about the effect if you've already seen what the coarser controls do.

cross_attn being weaker than self_attn at the same weight is expected, not a sign something's misconfigured - cross-attention governs prompt-following more than visual style, so it's a subtler lever for this specific job.

CategoryRES4LYF/sampler_extensions

Inputs (18)

NameTypeDefaultDescription
modeCOMBOscattersort10 options: none, scattersort_dir, scattersort_dir2, scattersort, tiled_scattersort, AdaIN, +4
block_typeCOMBOinput7 options: input, middle, output, input,middle, input,output, middle,output, +1
block_listSTRINGall
block_weightsSTRING1.0
norm1FLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
norm2FLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
norm3FLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
self_attnFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
cross_attnFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
ffFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
self_attn_resFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
cross_attn_resFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
ff_resFLOAT0.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