Nodes/ComfyUI-InpaintCanvas/Inpaint Canvas Mask Out
ComfyUI Node

Inpaint Canvas Mask Out

When a mask has to get back inside the editor

By DenRakEiw·Created 3 days ago·Updated about 20 hours ago· 10
Inpaint Canvas Mask Out
  • mask
    canvas_node
    purposesegment
    label

    Most nodes take data in and hand data out to the graph. Inpaint Canvas Mask Out does something most people don't realise a node can do: it hands data back into the editor. It has no outputs at all. It takes a MASK from a segmentation model and delivers it to the Inpaint Canvas editor, where it becomes the marching-ants selection - or, with the right purpose, a layer mask.

    This is the glue behind the editor's "select by text" helper. You type "shirt" into the editor, it queues a helper chain in front of your generation: a text-segmentation model (SAM3 through the RMBG nodes, or GroundingDINO plus SAM through the segment-anything pack) runs on the canvas image and produces a MASK for the shirt. Mask Out is what carries that mask back across the boundary. The editor turns it into a selection and fills in the object name the language model derived - that's the optional label.

    The inputs that matter

    • mask - the MASK from your segmentation model. A batch of masks is merged into one.
    • canvas_node - the id of the Inpaint Canvas node that asked for the mask. In the editor's generated helper chains this is filled in for you; it's how the node knows which editor to send the result to when several are in the workflow.
    • purpose - what the mask becomes back in the editor. segment (the default) delivers a selection. cutout delivers a layer mask instead - that's the path the editor's RMBG background-removal uses to turn a product shot into an editable transparency mask without touching its pixels.
    • label - optional text echoed back with the mask. When the language model reads your prompt and decides the object is a "bathing suit", that string rides along so the editor can show and reuse it.

    Under the hood it writes the mask as a grayscale PNG into temp/inpaint_canvas/ and sends a UI message containing the filename, the canvas id and the mask's coverage back to the frontend. That's the whole delivery mechanism - no graph edges involved, which is why it can cross from one chain into an editor that lives inside another node.

    Installing it

    It ships with the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DenRakEiw/ComfyUI-InpaintCanvas
    

    Restart ComfyUI. The node itself needs nothing, but the masks that flow through it only exist if you've installed a text-segmentation backend - the editor lists only the ones it finds, and comfyui-rmbg (SAM3) or comfyui_segment_anything (GroundingDINO + SAM) are the two it knows.

    Common issues

    • The mask never reaches the selection. If canvas_node is empty or points at the wrong Inpaint Canvas node, there's no address to deliver to. Leave it exactly as the editor's helper graph set it.
    • Nothing produces the mask. Mask Out is the delivery half - the model feeding mask has to exist first. Install the segmentation backend and let the editor re-queue the helper.
    • Selection vs layer mask confusion. If you expected a selection and got a transparency mask (or vice versa), check purpose. segment is for selecting what to inpaint; cutout is for the RMBG background-removal path.

    You'll likely never add one of these by hand. But when you see it sitting in a helper chain, now you know what it's for: it's the mailbox slot through which the outside world mails a mask back into your canvas.

    Categoryimage/inpaint

    Inputs (4)

    NameTypeDefaultDescription
    maskMASK
    canvas_nodeSTRINGId of the Inpaint Canvas node that asked for the mask.
    purposeSTRINGsegment
    labeloptSTRINGText that describes the mask (e.g. the object name a language model derived from the prompt); echoed back to the editor.

    Outputs (0)

    No outputs