Nodes/ControlAltAI Nodes/Region Mask Validator
ComfyUI Node

Region Mask Validator

Catch overlapping Flux regions before they wreck the render

By gseth·Created 2 years ago·Updated about a year ago· 209
Region Mask Validator
  • mask1
  • bbox1
  • mask2
  • bbox2
  • mask3
  • bbox3
  • valid_mask1
  • valid_bbox1
  • valid_mask2
  • valid_bbox2
  • valid_mask3
  • valid_bbox3
  • valid_region_count
  • is_valid
  • validation_message
  • validation_preview
number_of_regions1
min_region_size64
max_overlap0.10

This is the sanity check in the ControlAltAI Flux regional-prompting pipeline. You've drawn regions, softened their edges, and now you want to know: are these regions actually usable, or are they overlapping so badly that Flux is going to produce mush? Region Mask Validator answers that with a plain true/false plus a report on exactly which regions collide and by how much.

Regional prompting exists because Flux, like every diffusion model, applies conditioning globally - describe two subjects and their attributes swap and bleed. Masking each region's prompt to its own area is the fix. The catch, and it's the recurring one across every implementation of this technique, is that overlapping masks reintroduce exactly the ambiguity you were trying to kill. This node makes that failure visible before you burn a generation on it.

Where it sits

Pipeline order is: Region Mask Generator → Region Mask Processor → Region Mask Validator → Flux Region Conditioning → Flux Attention Control → (optional overlay) → Flux Attention Cleanup. By the time regions reach the Validator they've already been blurred and feathered. The Validator's job is to confirm the set is clean enough to condition on, then pass the validated masks forward.

How it works

It measures overlap between your region masks and checks each region against a minimum size. The method it uses technically wants zero overlap - but here's the reassuring part the README is explicit about: small overlaps get resolved downstream by feathering in Flux Attention Control, so they're not fatal. Overlap only becomes a real problem when it's excessive, roughly past the 40–50% mark. So treat a failed validation as a warning to read, not an automatic stop. If it flags 3% overlap, you're fine. If it flags 45%, your regions are fighting and you should redraw.

The inputs and outputs that matter

Feed it mask1 and bbox1 (and the optional mask2/bbox2, mask3/bbox3 pairs) coming out of the Processor, and set number_of_regions (1–3) to match. Two knobs actually shape the verdict:

  • max_overlap (default 0.1, range 0–0.5) - how much overlap you'll tolerate before is_valid flips to false. The 0.1 default (10%) is a reasonable line. Remember feathering saves you below ~40–50%, so if you understand what you're doing you can loosen this rather than obsessively redrawing masks to hit zero.
  • min_region_size (default 64, range 32–512) - the smallest a region is allowed to be. Tiny regions don't have enough spatial tokens to condition reliably; this catches a region you accidentally drew too small.

The outputs are where this node earns its place. is_valid (BOOLEAN) is your pass/fail - wire it to a logic node if you want to gate the run. validation_message (STRING) is the one to actually look at: it spells out which regions overlap and the overlap percentage, so you know what to fix, not just that something's wrong. validation_preview (IMAGE) shows the regions visually. And valid_mask1/valid_bbox1 through region 3, plus valid_region_count, carry the checked masks forward into Flux Region Conditioning.

How to install it

Through ComfyUI Manager: search ControlAltAI Nodes, install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/gseth/ControlAltAI-Nodes

then restart ComfyUI. The Validator has no dependencies of its own, but don't forget the pipeline it belongs to: Flux Attention Control requires XFormers, matched to your PyTorch version per the pack's xformers_instructions.txt. Get that installed before you commit to building the whole chain - validating masks is pointless if the stage that consumes them can't load.

Common issues & troubleshooting

is_valid is false but you don't know why. Read validation_message. It names the offending regions and the exact overlap percentage. That's the entire reason this output exists - don't guess when the node is telling you.

It fails on a small overlap you don't care about. That's the default max_overlap being strict. Since feathering downstream forgives overlaps up to roughly 40–50%, you can raise max_overlap and move on rather than redrawing perfect non-touching masks.

A region gets rejected for size. Your region is under min_region_size. Either draw it bigger back in the Generator or lower the threshold here - but a region that small often won't hold its prompt well anyway, so bigger is usually the right call.

Nodes don't show up after install. This pack has a track record of Manager-install glitches. Restart ComfyUI fully; if the ControlAltAI nodes still don't appear, remove the folder and re-clone it with git. Nothing in this node touches a model, so a model error means you've grabbed the wrong node.

CategoryControlAltAI Nodes/Flux Region

Inputs (9)

NameTypeDefaultDescription
mask1MASK
bbox1BBOX
number_of_regionsINT11–3
min_region_sizeINT6432–512
max_overlapFLOAT0.100–0.5
mask2optMASK
bbox2optBBOX
mask3optMASK
bbox3optBBOX

Outputs (10)

NameTypeDescription
valid_mask1MASK
valid_bbox1BBOX
valid_mask2MASK
valid_bbox2BBOX
valid_mask3MASK
valid_bbox3BBOX
valid_region_countINT
is_validBOOLEAN
validation_messageSTRING
validation_previewIMAGE