IsMaskEmpty (segment anything plus)
A one-number guard that stops wasted inpainting passes
- mask
- boolean_number
Some nodes generate images. This one answers a yes/no question, and the question is "did the segmentation find anything?" It takes a MASK, checks whether every pixel is zero, and returns 1 if the mask is empty, 0 if it isn't. That's the whole node - but in the right spot it saves you from the dumbest failure mode in automated ComfyUI workflows: running a full inpaint pass on a mask that contains nothing.
Why you'd reach for it: GroundingDinoSAMSegment only produces a real mask when its prompt actually matches something. Type pigeon into a photo with no pigeons and it returns an all-zero mask. Without a guard, your workflow happily proceeds to inpaint an empty region - wasting a sampling pass, or worse, producing a no-op that looks like a bug. Placing IsMaskEmpty right after the segment node turns that silent failure into a branch you can act on: feed the boolean_number output into a switch, a seed reroute, or any node that accepts a number condition, and skip the inpaint entirely when the detection came up dry.
The one thing to know
The output is a NUMBER (named boolean_number), not a real ComfyUI boolean. It returns a 1 or 0 as an integer tensor, so it plays nicely with nodes that branch on numbers - an Anything-style switch or a ConditioningSetMask toggle. If a node insists on a boolean input, you may need a small conversion step. It's a tiny friction, but it trips people up.
How it fits the wider workflow
This is the kind of node that makes the "Segment Anything plus" pack feel complete. It's a control-flow helper, not a content node - same role Impact Pack and other utility packs play: nothing it outputs is visible in the final image, but the graph runs only when it should because it's there. If you're building a batch workflow that segments many images with different prompts, this node is what keeps the failures cheap.
Installing
Same pack as the rest - one install covers all five nodes. ComfyUI Manager (search "ComfyUI Segment Anything") or:
cd ComfyUI/custom_nodes
git clone https://github.com/un-seen/comfyui_segment_anything_plus
No models to download for this one; it's pure tensor math (torch.all(mask == 0) under the hood). If you already have the pack installed for the segmentation nodes, this node is just sitting in your node list waiting.
The thing to double-check
Look closely at the node name in the search list: it's literally IsMaskEmpty (segment anything plus) - two spaces before the parenthetical, because the pack's author shipped it that way. Easy to type into a workflow JSON by hand and get "node not found". Grab it from the search palette and you'll never think about it again.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| boolean_number | NUMBER | — |