LayerUtility: Check Mask V2
Check Mask V2 — a finer-grained gate for empty masks
- mask
- bool
Same job as the original Check Mask: look at a mask, decide whether there's actually something meaningful in it, and hand back a boolean you can gate a downstream step on. It exists because automated masking - a detector, a SAM prompt, a background-removal pass - occasionally returns an effectively empty mask, and you don't want an inpaint, composite, or crop node running on nothing.
V2's real upgrade is precision. The original Check Mask only lets you set area_percent in whole-number steps from 1 to 99, which is fine for catching "basically nothing" but too coarse if you need to gate on a genuinely small-but-real detection - a distant object, a thin sliver of a mask edge. V2 makes that a float from 0 to 100 in 0.01 steps, and adds a method choice on top of it.
How it works
white_point still sets the brightness a mask pixel needs to clear to count as foreground, filtering out near-black noise. What's new is method: simple checks against area_percent directly (closer to how the original node behaved), while detect_percent changes how that area is computed - useful if the simple threshold is giving you false positives or negatives on masks with an unusual shape or a lot of scattered small regions rather than one solid blob.
The inputs and outputs that matter
mask- the mask to test.method-simpleordetect_percent. Start withsimple; switch if it's not matching what you'd expect by eye.white_point(1–254, default 1) - the foreground brightness cutoff.area_percent(FLOAT, 0–100, default 0.01, step 0.01) - the minimum share of the canvas required. The much finer step than the original node's integer version is the whole point - you can now gate on 0.05% instead of being stuck rounding to 1%.
Output: a single bool.
How to install it
Ships with the ComfyUI Layer Style pack. ComfyUI Manager - search ComfyUI Layer Style, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt
then restart. Lives under 😺dzNodes → LayerUtility. No models needed.
Common issues & troubleshooting
Result doesn't match what simple gave on the same mask. Try switching method to detect_percent - the two compute area differently, and a mask with scattered small regions (rather than one solid blob) can land on opposite sides of the threshold depending on which one you use.
Tiny detections keep passing when you wanted them filtered out. The default area_percent of 0.01 is extremely permissive by design - it's built to catch a genuinely near-empty mask, not to set a meaningful minimum size. Raise it explicitly to whatever real threshold your pipeline needs.
A legitimate but soft/partial-alpha mask reads as false. Lower white_point - matting-style masks are rarely hard black-and-white, and a high cutoff filters out real but partially-transparent regions along with the noise.
Node's missing from your palette. Pack import failure, not this node - LayerStyle's dependency chain is long, and transformers next to a stray TensorFlow install is the recurring way the whole pack fails to load together. Check the console or hit "Try Fix" in Manager.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| method | COMBO | 2 options: simple, detect_percent | |
| white_point | INT | 11–254 | — |
| area_percent | FLOAT | 0.010–100 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |