Nodes/ComfyUI-ZML-Image/ZML_遮罩分割
ComfyUI Node

ZML_遮罩分割

A mask-splitting node that doesn't need a mask — it makes its own

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_遮罩分割
    • 遮罩A
    • 遮罩B
    • 单独遮罩A
    • 单独遮罩B
    • 完整遮罩
    宽度1024
    高度1024
    分割比例0.5
    分割方向

    The name says "split mask," but the first thing to notice about ZML_MaskSplitNode is that it has no mask input. It takes width, height, a ratio, and a direction, and it generates the split masks for you. That makes it a geometry tool, not an image-analysis tool - and it's perfect for regional prompting, where you want "left half gets one prompt, right half gets another" without needing any detected content.

    It's the plain, dependable member of the ZML mask family. The fancy distance-based separation nodes (ZML_MaskSeparateDistance, ZML_MaskSeparateThree) split whatever's in a mask; this one ignores all that and just partitions empty space. Sometimes that's exactly what you want - a clean boundary with no guesswork.

    What it outputs

    Five masks, which is where the design gets slightly clever:

    • 遮罩A / 遮罩B - the two halves, each full size (width × height). Wire these to your two regional condtionings.
    • 单独遮罩A / 单独遮罩B - the same halves but cropped to their minimal bounding boxes. These are smaller tensors, handy if you're doing per-region work at actual resolution instead of full-frame masking.
    • 完整遮罩 - an all-white mask of the full canvas. Useful as a "everything" reference.

    The controls

    • 宽度 / 高度 (default 1024 each) - canvas size. This node doesn't inspect any image, so you are the source of truth on resolution. Match these to the resolution you're actually generating at, or the masks won't line up.
    • 分割比例 (0–1, default 0.5) - where the split lands. 0.5 is dead center; 0.3 puts more of the image in B.
    • 分割方向 - (vertical, left/right), (horizontal, top/bottom), or 对角线 (diagonal). The diagonal option is the recent addition (the README's 2025.09 update notes "遮罩分割节点新增了对角线遮罩"). Diagonal splits use a normalized x/w + y/h gradient, so the ratio slider still controls the split line's position.

    One caveat on the cropped outputs: for vertical splits, 单独遮罩A and 单独遮罩B are just the left and right bands, so they're clean. With diagonal splits the code copies the full masks into both "单独" outputs - they're not minimal bounding boxes in that mode. Not a bug per se, just something to not rely on.

    Wiring it in

    A common pattern: split the canvas, use the masks with SetLatentNoiseMask or a regional conditioning approach, and sample twice - once per region - then composite. The masks drop straight into any mask input because they're plain MASK tensors. If you're new to regional workflows, the KB's masking-detection-detailing doc is worth a read for how masks flow into conditioned sampling; this node just supplies the regions.

    Install

    It ships in ComfyUI-ZML-Image (the pack's 遮罩 subcategory), installed like everything else in the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    # restart ComfyUI
    

    or via ComfyUI Manager → search "ComfyUI-ZML-Image". No special dependencies beyond the pack's baseline (numpy, torch, Pillow). The interface is Chinese-first - 竖/横/对角线 mean vertical/horizontal/diagonal - and English speakers can grab the author's translation patch at https://github.com/zml-w/ZZZ_ZML_English_Patch.

    The usual pack note applies: it's a one-person project, "built for my own needs," so if a rarely-used node misbehaves the author wants an issue (or a PR). This node, though, is simple enough that it's been stable - it's mostly just numpy array filling, which is hard to get wrong.

    Categoryimage/ZML_图像/遮罩

    Inputs (4)

    NameTypeDefaultDescription
    宽度INT1024
    高度INT1024
    分割比例FLOAT0.50–1
    分割方向COMBO3 options: 竖, 横, 对角线

    Outputs (5)

    NameTypeDescription
    遮罩AMASK
    遮罩BMASK
    单独遮罩AMASK
    单独遮罩BMASK
    完整遮罩MASK