Nodes/ComfyUI Layer Style/LayerUtility: Check Mask
ComfyUI Node Runs on cloud

LayerUtility: Check Mask

Check Mask — did the mask actually find anything?

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerUtility: Check Mask
  • mask
  • bool
â—„white_point1â–º
â—„area_percent1â–º

A gate node, not an effects node. It looks at a mask and answers one question: is there actually anything meaningful in it, or is this effectively an empty mask? That sounds trivial until you've built a few automated pipelines - a face detector, a SAM prompt, a background-removal node - that occasionally return a mask with nothing (or almost nothing) in it, and everything downstream that assumed "there's a subject here" either errors or silently does something pointless on a blank region.

This node exists to catch that before it wastes a step. Feed it a mask, get back a boolean, and gate whatever comes next - skip the inpaint, skip the composite, branch to a fallback - based on whether the mask cleared your threshold.

How it works

Two thresholds work together. white_point sets the pixel-intensity cutoff a mask pixel has to clear to count as "foreground" at all - masks aren't always clean black-and-white, so this filters out near-black noise from counting. area_percent then sets the minimum share of the canvas that has to clear that cutoff for the check to return true. Below both thresholds, you get false - treat that as "nothing worth acting on here."

The inputs and outputs that matter

  • mask - the mask to test.
  • white_point (1–254, default 1) - how bright a pixel needs to be to count as foreground. Low values are permissive (almost anything counts); raise it if faint mask noise is giving you false positives.
  • area_percent (1–99, default 1) - the minimum percentage of the canvas that needs to clear white_point for the result to be true. The default of 1% is a low bar - it's built to catch "basically nothing," not to filter out small-but-real detections.

Output: a single bool - wire it straight into a switch or gate node.

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

It returns true on a mask that looks empty to you. area_percent defaults to 1%, which is a genuinely small share of the frame - a tiny cluster of falsely-detected pixels can clear that bar. Raise area_percent if you want the gate to only fire on a real, substantial detection.

It returns false on a mask that clearly has something in it. Check white_point - if your upstream mask is soft (partial alpha rather than hard black-and-white, which is common out of matting models), a high white_point can filter out a legitimate but not-fully-opaque region. Lower it.

You need a finer area threshold than whole percentage points. This node's area_percent only steps in whole numbers 1–99. The pack's Check Mask V2 replaces this with a float input down to 0.01% and adds a method choice between a simple threshold and a percent-based detection mode - worth switching to if 1% granularity is too coarse for what you're catching.

Node's not showing up in your palette. Pack import failure, not this node - LayerStyle's dependency chain is long, and a broken transformers/TensorFlow pairing is the classic way the entire pack fails to load at once. Check the startup console or hit "Try Fix" in Manager.

Category😺dzNodes/LayerUtility

Inputs (3)

NameTypeDefaultDescription
maskMASK—
white_pointINT11–254—
area_percentINT11–99—

Outputs (1)

NameTypeDescription
boolBOOLEAN—