DOGMAInpaintMaskV543
DOGMA Inpaint Mask v54.3
- mask
- mask
- mask_image
- info
A SAM mask is not an inpaint mask. SAM gives you the object's silhouette, and if you hand that straight to a diffusion model, two things happen: the object doesn't get a chance to change (there's no room around it), and the seam lands exactly on the silhouette, which is the worst possible place for a line.
This node fixes both, and the interesting bit is that you don't tell it how much to grow. It works that out from what kind of thing it is.
What it is
It's the "generation mask" builder in the v54 line - the mask that goes into the sampler, as opposed to the tighter mask you composite back through later. The distinction matters and the pack takes it seriously: the model should be allowed to paint a little wider than the region you actually keep, so the transition happens on generated pixels rather than on source pixels.
You already have the kind value by this point, because DOGMAGenerativeCategoryPromptV54 produced it from the category: OBJECT, STRUCTURE or SURFACE. That's the only control this node needs.
How it works
The mask is thresholded, then closed, then grown - and both the threshold and the amounts are derived from kind.
For OBJECT, threshold 0.18, a 3px closing and a 6px grow. Tight, because per-object work is where you want to keep generated pixels close to the target.
For STRUCTURE, threshold 0.20, a closing of 4% of the image's short side (clamped to 16–72px) and a grow of 0.8% of the short side (6–18px). For SURFACE, 0.28, 2% (8–40px), and 0.6% (4–12px). Scaling by the short side is the detail that makes this portable: the same node does something sensible on a 2K master and an 8K master, which a fixed pixel radius does not - and surfaces get less closing than structures because a bigger seal on foliage or tarmac starts welding unrelated regions together.
The closing is a morphological close - dilate, then erode - which fills holes and joins nearby fragments without inflating the overall footprint. That's what turns a scatter of per-instance SAM masks into one solid region you can crop and re-render coherently. Big images are handled by doing the close on a nearest-neighbour proxy (768px max side for STRUCTURE, 896 for SURFACE) and interpolating back, and then taking max(original, filled) deliberately: low-resolution morphology is allowed to add fill, never to replace the boundary SAM actually found at full resolution. That's a smart little guarantee, and it's the fix the "FAST" in the version name refers to.
The final grow is separable at full resolution, and everything ends as hard 0/1 - this is a generation mask, not a feathered one. A sibling node, DOGMADualMaskV545, is the one to reach for if you want the paired generation/blend masks in one go.
Inputs and outputs
Two inputs. mask (MASK) - the segmenter output, and it can be a batch; the node unions or handles the batch itself. kind (STRING, forced input) - you wire it from the prompt node, you don't type it. If it arrives as a list, the node takes the first entry.
Three outputs. mask (MASK) is the hard generation mask - that's the one that goes into your sampler's mask input, or into a masked-latent node. mask_image (IMAGE) is the same thing as a white-on-black image, useful for a quick preview or as an overlay. info (STRING) is the receipt, and it's a genuinely useful one: it reports the threshold it used, the closing radius and the resolution that closing ran at, the grow radius, and coverage before and after as a percentage. That coverage pair is how you catch a runaway mask - 2.3% to 31% means the closing sealed something enormous together.
Install
ComfyUI Manager → search DOGMA Nodes (publisher axior), install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI
No external Python dependencies - the pack's requirements.txt is a single "no external dependencies" comment - and no weights. This node is pure torch morphology.
Common issues
The one real gotcha is the assumption baked into kind. A mask grown by 6px around a small object on an 8K frame is a tight mask; the same 6px on a 2K frame is a generous one. OBJECT growth is deliberately resolution-independent, so if your frame is big and your cropped regions are small, you may want the SURFACE-style scaling and simply won't get it from this node. The crop nodes' context_px is the other place to add breathing room instead.
Second, if you wire this mask into a sampler and the result shows hard-edged rectangles creeping in, you've almost certainly used the generation mask at the composite stage. The composite wants a tighter, feathered mask - that's what the region-stitch node in the same version family does, eroding inward and feathering entirely inside the generated area so alpha is zero outside it. Mixing those two up is the most common way a working pipeline starts showing seams.
And the obvious upstream dependency: this reads the mask quality it's given. A SAM pass at too low a threshold delivers shadow blobs, and no amount of closing logic will un-invent them.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| kind | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| mask_image | IMAGE | — |
| info | STRING | — |