Nodes/SDVN Segment Anything/🧩 Is Mask Empty
ComfyUI Node

🧩 Is Mask Empty

The tiny node that routes around silent failures

By StableDiffusionVNΒ·Created 7 months agoΒ·Updated 7 months agoΒ· 1
🧩 Is Mask Empty
  • mask
  • boolean_number

Here's the situation that makes this node worth having: your workflow just ran a segmentation step, and the mask came back pure black. Did it find nothing, or did it find nothing on purpose? With SDVN IsMaskEmpty you stop guessing - it looks at a MASK, and if every pixel is zero it hands you a 1. The whole thing is torch.all(mask == 0), and that tiny test is surprisingly useful.

Why "did segmentation fail?" is a real question

The pack's segment nodes have a nasty habit: when your prompt matches nothing, they don't error out. SDVN DinoSAMSegment just returns an empty mask and keeps going. So a workflow that silently inpaints with a blank mask is happily doing nothing while looking like it's working - you get back your original image and wonder where the "fix" went. IsMaskEmpty is the tripwire. Wire its output into a switch or router node and you can route around the failure: use the full-image mask as a fallback, skip the inpaint step entirely, or trigger an alert.

That routing pattern is exactly what makes the node useful. Run it right after SDVN SegmentAnything or SDVN DinoSAMSegment, and you get a number you can feed into any conditional/switch node (core ComfyUI's switch nodes, or the ones from packs like rgthree). If it returns 1 (empty), the graph takes the fallback path; if 0, there's a real mask and the normal path runs.

The one thing people trip on

The output is named boolean_number and it's typed as a NUMBER, not ComfyUI's BOOLEAN type. Most switch nodes accept it fine, but if you try to wire it somewhere expecting a strict boolean you may get a type mismatch - keep it as a number and compare, or pass it into a node that coerces. And mind the polarity: 1 means the mask is empty (nothing found), 0 means there's something there. It reads like a method named isEmpty() would, which is the correct direction but easy to wire backwards if you're skimming.

Using it

One mask input, one NUMBER output, zero configuration, zero downloads, runs in microseconds. No model, no VRAM beyond the tensor already in memory. It's about as close to a free node as this pack gets.

The honest take

This is a niche utility, and it only earns its place if you're actually building conditional workflows - the kind where a batch of images gets segmented and you don't want a silent all-black mask to quietly eat a render pass. If you're just cutting out one subject by hand, you don't need it. The moment you automate, you do. It's also a nice complement to the pack's InvertMask: empty-check to detect failure, invert to fix polarity, segment to find - together they make the SAM/DINO machinery behave like part of a real pipeline instead of a one-shot demo.

Install

Part of SDVN Segment Anything - via ComfyUI Manager, or:

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

Restart and it's available immediately; like the rest of the utility nodes here, it never triggers a model download. Small node, quiet job - but it's the difference between a workflow that survives a bad prompt and one that silently wastes a render.

CategoryπŸ“‚ SDVN/🎭 Mask

Inputs (1)

NameTypeDefaultDescription
maskMASKβ€”

Outputs (1)

NameTypeDescription
boolean_numberNUMBERβ€”