ComfyUI Node

Regions Attention Mask

Patch the model so regional prompts actually apply

By Acly·Created 3 years ago·Updated about a month ago· 667
Regions Attention Mask
  • model
  • regions
  • model

This is the node that makes regional prompting real. You can build a whole list of regions - a background prompt plus masked areas for each subject - but until you patch the model, the sampler ignores all of it. ETN_AttentionMask (it shows up as "Regions Attention Mask") takes your finished region list and rewires the model so text prompts only fire inside their assigned areas. It's the last link in the chain and the one that does the actual work.

It's the payoff node in the regions section of Acly's ComfyUI Nodes for External Tooling - the attention-masking approach to keeping two characters from swapping hair colors, and the technique behind the seamless regional prompts in his Krita AI Diffusion plugin. Regional control is one of those needs that never went away: the community has run 20–40 threads a month about it for years, because prompt adherence is global and a single prompt describing two subjects reliably blends their attributes.

How it works

The node patches your MODEL to apply the list of regions during sampling, replacing the positive text conditioning that goes to the KSampler with the per-region attention-masked version. Each region's prompt is confined to its mask via the model's attention maps rather than by chopping the latent into hard boxes - the "attention couple" method, which the KB describes as less forceful and more natural-looking than crude area conditioning.

Crucially, this replaces the positive conditioning but leaves the rest of your conditioning stack alone. Per the README, "it's still possible to pass ControlNet and other conditioning to the sampler" - so you keep pose control, IP-Adapters, and your negative prompt while the regions handle the per-area text. One good habit from the KB: the cleanest results come from letting region masking establish the composition early and then blending back toward the base conditioning, rather than holding hard masks through every step, which is what produces the visible-seam collage look.

The inputs and outputs that matter

  • model (MODEL) - your base model. Wire your checkpoint (after any LoRAs) in here.
  • regions (Regions) - the region list built by ETN_BackgroundRegion and any Define Region nodes. This is required; the node has nothing to apply without it.

One output:

  • model (MODEL) - the patched model. Route it into your KSampler exactly where the unpatched model used to go. That's the whole integration: swap the model wire, and the sampler now honors your regions.

How to install it

Install the pack as a unit. ComfyUI Manager: search ComfyUI Nodes for External Tooling, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/Acly/comfyui-tooling-nodes.git

then restart. No downloads - it's model-patching code.

Common issues & troubleshooting

The regions don't take effect. Confirm the patched model output actually feeds the sampler. If your KSampler is still wired to the raw checkpoint, none of this applies. This node's output must be the model the sampler uses.

Masks are the wrong size. Region masks must match either the image size or the latent size (which is 8× smaller). A mask at the wrong scale will misplace or drop a region. Match your masks to one of those two resolutions.

Regions look boxy or seamed. You're likely holding the masks too hard for too long. The technique's characteristic failure is a collaged image with visible boundaries; the standing fix is to end masking once composition has formed and let the base prompt blend the rest. Also expect some bleeding when subjects share traits - that's the tradeoff attention masking never fully escapes.

Errors on a newer base model. Regional prompting is written against a specific attention layout and doesn't automatically port to every architecture. If it fails on an exotic model, that's the mismatch - this technique gets re-implemented per architecture rather than working everywhere.

Categoryexternal_tooling/regions

Inputs (2)

NameTypeDefaultDescription
modelMODEL
regionsRegions

Outputs (1)

NameTypeDescription
modelMODEL