Nodes/ComfyUI-JakeUpgrade/Is Mask Empty JK๐Ÿ‰
ComfyUI Node

Is Mask Empty JK๐Ÿ‰

Mask or no mask?

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Is Mask Empty JK๐Ÿ‰
  • mask
  • BOOLEAN

Here's the scenario that made this node necessary: your workflow auto-generates a mask - from segmentation, from a face detector, from ControlNet preprocessing - and sometimes that detector comes back with nothing. The mask is all zeros. If you blindly run an inpaint pass on an empty mask, you waste a full generation on a no-op, or worse, you get garbage where the model "fixed" something that wasn't there. Is Mask Empty JK is the guardrail that catches that before it happens.

What it does

One input, one output. Feed it a MASK, and it checks whether every single pixel is zero. If the mask is completely empty, the BOOLEAN output is True; if there's any nonzero pixel anywhere, it's False. Under the hood it's a single torch.all(mask == 0) - trivial, and exactly what you want from a node like this.

It landed in the pack back in v1.7.0 alongside the image-crop-by-mask group node, and it's been quietly doing branch logic in Jake's inpaint and auto-mask workflows ever since.

How you actually use it

The output is a BOOLEAN, so wire it into any switch, router, or conditional node in your graph - the pack's own Bool nodes work great - and branch:

  • True (empty mask) โ†’ skip the inpaint/refine pass entirely, route the image straight through.
  • False (something to fix) โ†’ run the pass.

That's the whole trick. It turns "hopefully the detector found a face" into a real decision the graph makes per image. In batch workflows this is gold: you can run 50 images and only spend GPU time on the ones that actually need work.

Where beginners get burned

Two things. First, an almost empty mask is not empty. If a mask has any anti-aliased edge - even one pixel at 0.5 instead of 0 - this node reports False. Soft feathered masks from some preprocessors will basically never count as empty, which is usually the right call for inpainting anyway, but it can surprise you if you expected a crisp "nothing here."

Second, remember the polarity: True means "don't do the work," which trips people up the first time. If your workflow runs the inpaint pass when it should skip it, check that your branch treats True as the skip path.

Install

Standard JakeUpgrade install - clone into custom_nodes, install requirements, restart:

cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
pip install -r requirements.txt

No models, no heavy dependencies. If it's not in your palette after updating, remember the pack's config.ini controls which modules load - this one lives in the mask module, which defaults to enabled. Usually the fix is just a restart after git pull.

Category๐Ÿ‰ JK/๐Ÿ“ Mask

Inputs (1)

NameTypeDefaultDescription
maskMASKโ€”

Outputs (1)

NameTypeDescription
BOOLEANBOOLEANโ€”