Is Mask Black
Is this mask empty? Ask it instead of squinting
- mask
- boolean
A detector ran, a SAM prompt failed, a background remover choked - and the mask it produced is black. Empty. Nothing there. If you feed that into an inpaint pass you get a no-op at best and a confusing wasted run at worst. wcx_IsMaskBlack exists to catch exactly that moment: one mask in, one boolean out, and the boolean tells you whether the mask is all black (i.e., nothing is actually masked).
The logic is dead simple and worth knowing precisely: it returns True if the mask is None or if every single pixel is 0. In ComfyUI's MASK convention, black means "not masked," so "all black" and "nothing selected" are the same thing. Any nonzero pixel at all flips it to False.
Which makes it a natural gate in an automated loop. The KB's masking doc describes the whole detect-mask-inpaint loop; this node is the "should I even bother" check at the top of it. Wire the boolean into a switch or boolean logic node, and you can route around the empty mask: skip the inpaint, substitute a fallback mask, or log "detector failed on this frame" and move on. It's the plumbing-doc's graph-as-a-program idea applied to a very real failure mode.
Two subtleties that bite people:
- It's all-or-nothing across the whole batch.
torch.all(mask == 0)checks every frame in the batch. If you feed a 16-frame video mask batch and frame 3 has content, you get False even though 15 frames are empty. Test single frames (pull one out with something likewcx_IndexAnything) if you care per-frame. - Near-black isn't black. A mask sitting at 0.001 is technically "not black" to this node, even though it's visually empty and will barely affect a denoise. If your pipeline produces faint-but-not-zero masks, you may want a threshold instead.
Input is mask (MASK), output is boolean (BOOLEAN). Nothing else to configure, which is refreshing.
Install is the pack's standard light path - no dependencies, no models:
# ComfyUI Manager: search "ComfyUI-Practical-Tools" → Install → restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
# restart ComfyUI
It's a tiny node, but the automation it unlocks - actually handling empty masks instead of pretending they didn't happen - is the difference between a batch that runs and a batch you babysit.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| boolean | BOOLEAN | — |