Nodes/ComfyUI-Muye-nodes/遮罩填充漏洞
ComfyUI Node

遮罩填充漏洞

Close the holes inside your mask so inpainting covers the whole subject

By muyexiuluo·Created about a year ago·Updated 23 days ago· 89
遮罩填充漏洞
  • 遮罩
  • 填充遮罩

Detector masks are full of holes. A face detector might grab the skin but leave the eyes and mouth as gaps; a background-removal mask can have specular highlights punched out of it; a segmentation mask over a person frequently has little voids where the model decided "not sure." For previewing a mask, holes are fine. For inpainting, they're a leak: the un-masked hole becomes the one patch your sampler re-renders on its own terms, and you get a weirdly clean eye or a re-painted highlight staring out of an otherwise untouched region.

MaskFillHoles is the two-second fix: feed it a mask and it fills every enclosed void inside the white regions, leaving the outer shape intact. One input, 遮罩, one output, 填充遮罩. It's a classic morphological close - under the hood it's scipy's binary_fill_holes, which is the standard tool for exactly this. A white region with a black hole in the middle becomes solid white; the surrounding black stays black.

This is the kind of node you don't think about until you need it, then it's in half your inpainting workflows. The KB's masking-and-detailing doc stresses how often the re-render pass is only as good as the mask that feeds it - and a holey mask is the quiet way to get "why did it redraw her eye" results. Sticking MaskFillHoles between your detector and your detailer/inpaint node is cheap insurance.

A couple of honest limits. First, it fills enclosed holes - a white region that's C-shaped with an opening to the outside stays C-shaped, because that's not an enclosed hole. Second, the output mask is binary (thresholded at 0.5), so any soft-feathered edges on your original mask get flattened. If your downstream step relies on feathered mask edges for seamless blending, you'll want to re-blur the filled mask afterward. For a big inpaint region that's usually a fine trade; for hair or fur edges you may want the original. Both limitations are the normal cost of this operation, not bugs.

It needs scipy, which is in the pack's requirements.txt - one of the few utility nodes here with a real dependency beyond torch.

Install

ComfyUI Manager → search "muye" → install "ComfyUI-Muye-nodes", restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/muyexiuluo/ComfyUI-Muye-nodes
cd ComfyUI-Muye-nodes
pip install -r requirements.txt

then restart. If the node is missing, scipy almost certainly didn't install - pip install scipy fixes it. The README's manual block references an older ComfyUI_Muye.git URL; use the -nodes one above. Display name is 遮罩填充漏洞; if the module fails to import for any reason, the console shows [Muye] Failed to load module and the node silently disappears - check that line before you reinstall the whole pack.

CategoryMuye/Mask

Inputs (1)

NameTypeDefaultDescription
遮罩MASK

Outputs (1)

NameTypeDescription
填充遮罩MASK