Nodes/SimpleSyrup/Attention Region Mask
ComfyUI Node

Attention Region Mask

A mask of what the model was actually looking at

By Artificial-Sweetener·Created 4 months ago·Updated 2 days ago· 2
Attention Region Mask
  • latent
  • latent
  • mask
conceptssubject
sampler_stage1
capture_start0.00
capture_end1.00
minimum_strength0.15
minimum_consensus0.25
geometry_recall0.85
split_sensitivity0.00
instance_recall0.65
minimum_region_size512
keep_only1
keep_bylargest size
combine_segsfalse
matte_solidity0.75
edge_feather8
capture_profilefast
evidence_modeconcept isolation

Most masks come from detectors or your own brush. This one comes from somewhere stranger: the cross-attention maps of the sampler that already made your image. Give it a latent from a past generation pass and a concept like hair, and it returns a soft mask of the pixels that model actually associated with "hair" while denoising. No GroundingDINO, no SAM, no drawing. If the concept never rendered, the mask knows - because the attention was never there.

How it works

It belongs to SimpleSyrup's attention-capture family, and understanding one of them is understanding all of them. While the upstream sampler ran, the pack recorded which spatial regions attended to which prompt tokens (see Attention Capture Model for the plumbing). This node walks your graph backward from the connected latent, finds that sampler, reads the captured evidence for the concepts you asked about, and renders it into a mask.

Two things to notice about the output. It's a soft, latent-resolution mask - the union of every matched region, with alpha shaped by the matte_solidity and edge_feather controls. And the latent input passes through unchanged, so you can insert this node into a wire without rerouting anything.

Inputs that matter

  • concepts - the concept or concepts whose attention becomes the mask, separated by |. Default is subject. These should match words that actually appear in the positive prompt of the sampler that made the image. girl | pink hair | cat is the shape the tooltips use.
  • sampler_stage - which sampler in the chain to read. 1 is the first, 2 the second, 0 or -1 grabs the last. If your image came from a plain first pass, leave it at 1.
  • capture_start / capture_end - which slice of denoising counts as evidence. Later starts skip the initial composition phase; earlier ends ignore late refinement. The defaults (0 → 1) take everything, which is usually right.
  • minimum_strength - the main quality knob. It's the minimum normalized attention retained per region; raise it to narrow the silhouette toward the concept's semantic core, lower it to keep its halo.

The rest of the knobs (minimum_consensus, geometry_recall, split_sensitivity, instance_recall, minimum_region_size, keep_only, keep_by, combine_segs, evidence_mode, capture_profile) are shared across the whole family and tuned well enough at defaults that beginners can ignore them. evidence_mode is the one worth knowing: default concept isolation gives a cleaner stable region, while raw attention shows the captured probabilities unprocessed.

What to do with it

The mask output is a plain MASK, so it feeds everything mask-based: a mask-blur before an img2img pass, a Set Mask for inpainting, conditioning a detailer, or as the "only this region" boundary for a regional sampler. Wire the latent passthrough straight through and put the mask where masks go. It's the cheapest route to a "refine only what the prompt controlled" mask you'll find.

Where people stumble

The big one is provenance: the latent has to trace back to the sampler in the same graph, unmodified by editing, cropping, or resampling between. The node resolves the sampler from the graph, and if it can't recover one you get nothing - no crash, just an empty result. Second, if a concept wasn't in the positive prompt, or the sampler never really attended to it, the region is empty or tiny; check your spelling and that the concept rendered. And keep expectations set: these are soft, latent-resolution silhouettes, not pixel-hairline mattes. That's a feature for conditioning work and a limitation for cutout work.

It ships in SimpleSyrup - Manager search SimpleSyrup, or clone into custom_nodes and install requirements.txt. No model downloads for this node; the pack's heavier dependencies (Ultralytics, ONNX, SAM) serve its detector nodes, not this one.

CategorySimpleSyrup/Masking

Inputs (18)

NameTypeDefaultDescription
latentLATENTLatent whose graph provenance identifies the upstream sampler; the latent is returned unchanged.
conceptsSTRINGsubjectConcepts whose attention becomes the mask, separated by |.
sampler_stageINT1-1–1024Selects the connected sampling stage: 1 is first, 2 is second, and 0 or -1 selects the last; oversized values use the last.
capture_startFLOAT0.000–0.99Start of denoising evidence to include; later values ignore more of the initial composition phase.
capture_endFLOAT1.000.01–1End of denoising evidence to include; earlier values ignore more late refinement attention.
minimum_strengthFLOAT0.150–1Minimum normalized attention association retained in a region; higher values narrow the silhouette toward its semantic core.
minimum_consensusFLOAT0.250–1Fraction of selected observations that must support a pixel; higher values keep more persistent regions.
geometry_recallFLOAT0.850–1Higher values recover fainter connected object extent from exact attention, preserving tails and shafts but admitting more halos.
split_sensitivityFLOAT0.000–1Sensitivity to divide one connected region around separate peaks; higher values can split a soft silhouette into multiple instances.
instance_recallFLOAT0.650–1Higher values retain weaker disconnected instances relative to the strongest one, which helps repeated sparse concepts.
minimum_region_sizeINT5121–1048576Discard attention components smaller than this many pixels.
keep_onlyINT10–1024Keep the best N instances per concept; 1 keeps the largest and 0 keeps all.
keep_byCOMBOlargest sizeRanks retained instances by area or attention confidence.
combine_segsBOOLEANfalseCombines retained instances of each concept into one SEG.
matte_solidityFLOAT0.750–1Higher values flatten accepted interiors toward fully opaque alpha.
edge_featherINT80–4096Width in output pixels of the matte boundary transition.
capture_profileCOMBOfastControls observation density: fast minimizes overhead, balanced adds temporal evidence, and exhaustive retains every eligible call.
evidence_modeCOMBOconcept isolationConcept isolation derives a cleaner stable region; raw attention shows the captured model probabilities without isolation weighting.

Outputs (2)

NameTypeDescription
latentLATENTUnchanged connected latent.
maskMASKSoft latent-resolution union of matched regions.