Nodes/ComfyUI-PolyMask/Poly Mask Loader
ComfyUI Node

Poly Mask Loader

The simplest mask editor in ComfyUI (and one real trap)

By Carasibana·Created 9 months ago·Updated 5 months ago· 3
Poly Mask Loader
    • IMAGE
    • MASK
    image
    feathering0
    polygon_points[]

    This is the lightweight member of the ComfyUI-PolyMask family - a single-polygon version of the pack's Multi node. No additive/subtractive rows, no base-layer toggle. You get one canvas, one polygon, and a mask out the other side. For the most common job in this corner of ComfyUI - "mask one region of this image and inpaint it" - that's genuinely all you need, and it's less fiddly than the six-polygon sibling.

    What it is and how it works

    It's an image loader with a polygon lasso bolted onto the front. A JavaScript extension that ships with the pack draws an interactive canvas right on the node: left-click adds a point, drag moves one, click on a line inserts a point, right-click deletes. The points serialize into a JSON string widget, polygon_points, and the Python side rasterizes them with PIL's ImageDraw into a mask. Same EXIF-orientation handling and RGBA→white compositing as the Multi node, and the same IS_CHANGED trick so downstream nodes re-run as you drag points around.

    One mechanism detail worth knowing: feathering here works like the Multi's. It takes the max of the original mask and a Gaussian blur of it, so higher feathering values add a halo that expands the mask outward rather than just softening the boundary. Keep it low for a crisp region.

    The inputs that matter

    • image - a dropdown of everything in your ComfyUI input folder, with an upload button.
    • feathering (0–100) - mask-edge blur. 0 is hard; a few pixels if you're seeing seams where the edit meets the original.
    • polygon_points - the JSON string the canvas writes for you. You don't type this.

    Outputs are IMAGE and MASK. Feed the MASK into Set Latent Noise Mask for classic masked inpainting or InpaintModelConditioning for the newer edit models; the IMAGE output means the node also works as a LoadImage, so mask and source stay in one place.

    Install

    Same pack as the Multi - install once, get both nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Carasibana/ComfyUI-PolyMask.git
    

    Or use ComfyUI Manager and search "PolyMask". Restart ComfyUI, then hard-refresh the browser tab (the editor is a frontend extension, and it's the first thing people miss). No model downloads, no heavy dependencies - just torch, numpy, and Pillow, which are already part of ComfyUI.

    The trap

    Fewer than three points, and this node returns a full white mask - not an empty one. The source does return np.ones((height, width)) when the point list is under 3. So if you place a point or two and hit run, you've told every downstream node "mask everything," which for an inpaint means regenerating the entire frame. The Multi node at least skips an undersized polygon silently; this one inverts it into a worst-case mask. If an inpaint suddenly wipes your whole image, this is the first thing to check.

    Bottom line

    Reach for it when you want one region and nothing fancy. The moment you need a hole, multiple shapes, or subtractive cutting, step up to Poly Mask Loader (Multi) - same install, same pack, and it handles all of it.

    Categoryimage

    Inputs (3)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    featheringINT00–100
    polygon_pointsSTRING[]

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK