Mask Empty Float (CRT)
Did that mask actually find anything? Ask it, get a number
- mask
- float_output
Masks are the quiet failure point of a lot of workflows. You run a segmentation or a face-detect node, pipe the mask downstream, and never actually check whether it found anything - then wonder why your inpaint pass changed nothing. Mask Empty Float (CRT) exists to turn that unspoken question into a number your graph can act on.
It's a logic/values utility from CRT-Nodes: one mask in, one float out. Nothing fancy, but it's the difference between "I assume there's a mask" and "I know there's a mask."
How it works
The mechanism is brutally simple - it converts the mask to a tensor, checks whether every pixel is zero, and returns:
0.0if the mask is completely empty (all black),- your value_if_non_empty (default
1.0) if any pixel is non-zero.
That's it. One np.all(mask == 0) check, no detection, no thresholds.
Inputs and output
- mask - any MASK tensor. From a segmentation node, a ControlNet-ish output, an inpaint setup, whatever.
- value_if_non_empty - what to output when the mask has content. Default 1, range 0–1. You can set it to something else if you want a specific strength to pop out.
Output is float_output, a plain FLOAT. Because it's a float, you can feed it straight into a Math node, a strength input, or a boolean gate - floats are the lingua franca of ComfyUI's logic layer.
Where you'll use it
- Route around empty detections. "If no face was found, skip the face-restoration pass" - mask float feeds a switch, and the branch just doesn't fire.
- Dynamic strength. Set
value_if_non_emptyto 0.7 and you've got a ready-made strength that appears only when there's something to process. - Inpaint sanity checks. Confirm your inpaint region actually got a mask before you commit a long sample.
It's a small node, and the honest review is: it's one of those "build once, use constantly" utilities that doesn't do anything dramatic on its own but makes conditional workflows readable. The alternative - eyeballing masks on a Preview Image node and hoping - is worse.
Install
Pack-level: ComfyUI Manager → search CRT-Nodes → install and restart, or git clone https://github.com/PGCRT/CRT-Nodes into ComfyUI/custom_nodes. It sits in the shared suite with the full dependency footprint (opencv, scipy, ultralytics, librosa and friends), so this tiny node comes with the whole pack's install weight - fine if you're using other CRT nodes, overkill if this is the only one you want.
Troubleshooting is minimal. The one thing to remember: masks are floats in [0,1], and "empty" means all zero - a mask that's 99% black but has one bright pixel still counts as non-empty. If your logic feels backwards, that's usually why.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| value_if_non_empty | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| float_output | FLOAT | — |