ComfyUI Node

Mask Generator

Solid white or black masks on demand — the cure for 'mask count doesn't match frames'

By baicai99·Created 2 years ago·Updated about a year ago· 15
Mask Generator
    • MASK
    num_masks1
    mask_height512
    mask_width512
    mask_color

    In ComfyUI a mask is just a single-channel tensor of floats from 0 to 1, shaped (frames, height, width). And the moment you're doing video, masks turn into bookkeeping hell: slice your image batch down to 24 frames, and the mask batch that came with it is still 120 frames, and suddenly everything downstream is throwing shape-mismatch errors. Mask Generator is the author's blunt answer to that: give me N blank masks at whatever size, white or black, and stop making me count.

    Under the hood it's almost embarrassingly simple. Pick a color and it calls torch.ones(...) or torch.zeros(...) to build a (num_masks, mask_height, mask_width) float32 tensor. That's the entire mechanism - no model, no preprocessor, nothing to download. It exists purely so your mask count can match your image count one-to-one, which the pack README names as the exact problem it was built to solve: preventing errors caused by masks not corresponding one-to-one with images.

    The inputs that matter: num_masks (how many blank mask frames you need - set it to match whatever you sliced your images down to), mask_height and mask_width (default 512 each, and yes they should match your frame resolution if you're going to composite), and mask_color, which is just a white/black dropdown. The output is a single MASK tensor. Wire it into a mask-aware node that needs full coverage - inpainting being the obvious one. A solid white mask in ComfyUI's inpainting convention means "regenerate everything," so white is the blanket choice; black is "mask nothing," or raw material if you're going to punch holes in it later with other mask math.

    Three honest caveats. First, there's no batch-size cap beyond the 4096 height/width ceiling, but don't generate 1,000×4096 masks unless you enjoy watching your VRAM spike. Second, it only makes solid fills - no gradient, no animated mask, no "black in the middle, white outside." The README has those on a to-do list under "Mask Editor," but as of now they don't exist; if you need shaped masks, you're in compositing-node territory, not this one. Third, a genuine quirk: the output is (N, H, W) with no channel dimension, which is correct for the MASK type - don't let the missing third dimension spook you when you inspect it.

    Install is one step: ComfyUI Manager → search "ComfyUI-FrameSkipping", or clone the repo into custom_nodes and restart. No dependencies, no models, no requirements.txt to fight with. It's a small, boring utility - and boring is exactly what you want at frame 47 when you just need a blank mask that lines up.

    Categorybaicai/mask

    Inputs (4)

    NameTypeDefaultDescription
    num_masksINT1
    mask_heightINT5121–4096
    mask_widthINT5121–4096
    mask_colorCOMBO2 options: white, black

    Outputs (1)

    NameTypeDescription
    MASKMASK