ComfyUI Node

Mask Node

Colored segmentation maps in, 15 body-part masks out — the Virt-A-Mate bridge for ComfyUI

By McKlinton2·Created about a year ago·Updated about a year ago· 6
Mask Node
    • female_body
    • female_face
    • female_hair
    • female_breast
    • female_hands
    • female_vag
    • male_body
    • male_face
    • male_hair
    • male_hands
    • male_pen
    • male_pubic
    • female_full
    • male_full
    • all_gens
    • color
    • depth
    • segmentation
    • prompt
    folder
    index0
    random_indexfalse
    resize_modekeep original
    width512
    height512

    Here's the honest one-liner: this node turns pre-rendered segmentation maps into clean per-body-part masks so you can inpaint exactly one anatomical region of a Virt-A-Mate render and leave the rest alone. It's called "Mask Node" in the node list, and it's the star of the McKlinton Pack - the whole pack exists to glue Virt-A-Mate (VAM) scene exports into ComfyUI inpainting workflows.

    If you're not a VAM user, stop reading now - this node matches a fixed set of 12 exact RGB colors and nothing else, so pointing it at random images gives you zero masks and a confused afternoon. If you are a VAM user, this is the missing glue: the author (McKlinton, a Patreon VAM creator) built it to pair with his SnapshotAnimator plugin, which exports the color_, depth_, masks_, and prompt_ file sets the node expects. People in the wild use it exactly as shipped - the one community thread that names it describes it as "a node pack that does masking for all anatomy" for fixing genitals via segmentation.

    What it actually does

    Drop in a folder path and the node reads one image set - picked by index, or randomly with random_index. The masks_ file is a colored segmentation map where each body part has been painted its own RGB value (female body is pure blue, male hands orange, and so on). The node matches those exact colors in HSV space and returns each part as its own MASK tensor:

    • 12 individual masks: female_body, female_face, female_hair, female_breast, female_hands, female_vag, and their male counterparts (male_pen, male_pubic, …).
    • 3 combined masks: female_full, male_full, and all_gens - unions of the parts, handy when you want "all of her" or "everything down there" in one mask.
    • Pass-throughs: color (the RGB render), depth (the depth map, ready to feed a ControlNet depth preprocessor), segmentation (the raw colored map), and prompt - the text from the matching .txt file, so you can re-use the scene's prompt without hunting for it.

    Every mask comes out as a proper ComfyUI MASK, so it plugs straight into an Inpaint node, a VAE-encode mask, or a ControlNet conditioning. That's the whole point: mask one region, inpaint just that, keep the rest of the render.

    The inputs that matter

    • folder - the directory holding the file sets. Files must share one base name: masks_<name>.png, color_<name>.png, depth_<name>.png, prompt_<name>.txt.
    • index / random_index - pick a set by number, or let it roll. Random is nice for iterating through a scene dump.
    • resize_mode - keep original (default), resize (stretches to width/height, aspect ratio be damned), or resize and crop (fits and center-crops). Keep original unless your sampler needs a fixed size; the stretch mode warps masks and looks wrong on faces.

    Install

    ComfyUI Manager is the easy road: search the pack title and install. Otherwise:

    cd ComfyUI/custom_nodes
    git clone https://github.com/McKlinton2/comfyui-mcklinton-pack
    # restart ComfyUI
    

    No model files to download - it's pure code on top of OpenCV. Note the requirements.txt installs three OpenCV variants (plus numpy, Pillow, torch); torch you already have, and the triple OpenCV is redundant bloat that has bitten people, so if your venv gets cranky, pip uninstall the extras and keep one.

    Where people get burned

    • Exact color matching only. Anti-aliased edges or any remapped palette produce holes in the mask. It's HSV inRange with a zero-width range - either the pixel is exactly that color or it isn't.
    • Index out of range throws a hard error; missing a masks_ file returns a zero mask instead, which is worse - your inpainting silently does nothing.
    • The folder convention is the contract. If SnapshotAnimator didn't write the files with the right prefixes, the node finds no valid sets and refuses to run.

    For general (non-VAM) anatomy masking, Impact Pack with a NudeNet/ADetailer detector is the more general tool. But inside the VAM pipeline this is the one that just works.

    CategoryMcKlinton/masking

    Inputs (6)

    NameTypeDefaultDescription
    folderSTRING
    indexINT00–100
    random_indexBOOLEANfalse
    resize_modeCOMBOkeep original3 options: keep original, resize, resize and crop
    widthINT51264–4096
    heightINT51264–4096

    Outputs (19)

    NameTypeDescription
    female_bodyMASK
    female_faceMASK
    female_hairMASK
    female_breastMASK
    female_handsMASK
    female_vagMASK
    male_bodyMASK
    male_faceMASK
    male_hairMASK
    male_handsMASK
    male_penMASK
    male_pubicMASK
    female_fullMASK
    male_fullMASK
    all_gensMASK
    colorIMAGE
    depthIMAGE
    segmentationIMAGE
    promptSTRING