Nodes/Pitch Mask Fallback/Pitch Masque Plein si Vide
ComfyUI Node

Pitch Masque Plein si Vide

Detector found nothing? This node hands your pipeline a full white mask

By pitch7900·Created 7 months ago·Updated 7 months ago· 0
Pitch Masque Plein si Vide
  • mask
  • mask

The display name is French - Pitch Masque Plein si Vide - but the job is dead simple once you translate it: "full mask if empty." You feed it a MASK, and if that mask is entirely black it hands you back an entirely white one. If the mask has anything at all in it, it passes the original through untouched. That's the whole node, and it's genuinely useful.

Here's why it exists. Every automatic-detection loop in ComfyUI - a face detector, a Grounded SAM segmenter, an object tracker - fails sometimes. The detector runs, finds nothing, and emits an empty mask. Downstream, an inpainting or detailing pass over an empty mask does nothing at all, or worse, errors out mid-batch. In a batch of a hundred frames you won't notice one region silently skipped until you're staring at a broken render at the end. This node is the plumbing-layer insurance against that: it converts "detection failed" into "process the whole image," so the frame gets touched instead of silently abandoned. It's the same first-non-null fallback idea rgthree's switches use, but for masks specifically.

How it works

The mechanism is honest and small. The node copies your mask to CPU as float, checks whether its maximum value is zero, and if so replaces it with torch.ones_like - a full white mask. There's no threshold here, no "mostly empty" cleverness: it's a binary empty-or-not test. One stray bright pixel anywhere in the mask makes it count as non-empty, which is usually what you want (a genuine detection, however small, survives), but worth knowing if your detector spits out one-pixel noise.

The input/output pair is exactly as spare as the logic:

  • mask (MASK) - whatever your detector or segmenter produced.
  • mask (MASK) out - the original if non-empty, full white if empty. Wire it into whatever consumed the original mask; nothing else changes.

Installing it

This node ships in the pitch7900/ComfyUI-PitchCustomNodes pack alongside five others (a second mask node and four MMAudio audio nodes). The README is effectively empty, so don't go looking for docs there - the source code is the documentation. Easiest route:

  1. Install via ComfyUI Manager - search for "Pitch Mask Fallback" (the pack's display name) or "PitchCustomNodes" and hit install, then restart ComfyUI.
  2. Or from a terminal:
cd ComfyUI/custom_nodes
git clone https://github.com/pitch7900/ComfyUI-PitchCustomNodes

then restart. Manager will pull the pack's dependencies (accelerate, open_clip_torch, huggingface_hub, omegaconf, einops) - they're mostly there for the MMAudio side, but the install is the same for the whole pack. No model files needed for this node; it's pure tensor logic.

Common issues

  • The node prints a lot. Every run logs [PitchMaskFallback] lines about shape, dtype, and max value to the console. Harmless, occasionally useful for debugging an empty mask, but it can bury the real errors in a big workflow.
  • A "clean" mask that isn't. If your detector returns a mask that's visually blank but maxes at a tiny nonzero value, this node treats it as non-empty and passes it through. Pair it with PitchMaskAreaCondition from the same pack to cover the other failure mode - when the detector overreaches instead of under-finding.

That pairing is the real reason to install the pack: Fallback handles "found nothing," AreaCondition handles "found everything." Together they keep your detection loop honest at both ends.

CategoryPitch

Inputs (1)

NameTypeDefaultDescription
maskMASK

Outputs (1)

NameTypeDescription
maskMASK