DOGMA FinalCleanMasks v1.0.11
Fix pinholes in your approved masks without eating the object
- review
- approved_instances
- report
What it is
DOGMAFinalCleanMasksV111 is the last mask node before you start cutting crops: it takes an audited DOGMA_REVIEW, converts it into a batch of approved masks, and then does one small, tightly bounded repair pass on them.
That repair pass is the whole reason this exists as a separate node from DOGMAFinalCoverageV110, and the reason it has an on/off switch. SAM masks - especially text-prompted ones - often come back with pinholes: a pixel or three inside the object that the model decided were background. Left alone, those holes travel all the way downstream to your inpaint or re-render pass and show up as speckles or flicker in the final composite. The obvious fix is morphological closing, and that's exactly what this node refuses to do.
How the cleanup actually works
It calls DOGMAFinalCoverageV110 to get the finished masks and report, then, if clean_micro_holes is on:
scipy.ndimage.binary_fill_holesfinds enclosed holes - regions of mask that are surrounded by mask. Notches on the silhouette edge are not holes and are left alone.- Those holes are labelled and measured in analysis pixels. Only holes of 4 pixels or smaller are kept as fix candidates.
- The fix is applied only if the total repaired area is at most 0.5% of that instance's area. Bigger repair, no repair.
Then it stops. No dilation, no closing, no largest-component pruning, no filling of genuine openings. The author's code comment is unusually explicit about what it's protecting: architectural arches stay open, and small subjects don't get swallowed.
The output report inherits the coverage report and appends a line with the literal pixel count it changed, so you can tell whether the toggle did anything:
Micro-hole repair: 37 pixels; no silhouette dilation, no object deletion, holes larger than 4 analysis pixels preserved.
Inputs and outputs
review- aDOGMA_REVIEW, i.e. the output of one of the review nodes (DOGMAReviewBatchV111,DOGMAFinalMasksV109's upstream chain,DOGMAInstanceReviewV109, …).clean_micro_holes- boolean, default true. Turn it off when you're segmenting something with real small openings in it and you'd rather not trust the 4-pixel rule: window grilles, netting, foliage, cage bars, filigree. Those are exactly the case where an "enclosed hole" is content, not a defect.
Outputs:
approved_instances(MASK) - a mask batch (one mask per approved instance), or an empty batch if nothing survived. Wire this into a crop node such asDOGMAObjectNativeCropsV111, or into core mask nodes / SEGS conversion.report(STRING) - coverage, audit verdicts and the repair line. Worth keeping on aShow Textnode; it's the only place the decisions are visible.
Where people get confused
"It didn't fix my mask." Two likely reasons. First, the hole isn't enclosed - if the mask has a bite out of its edge, binary_fill_holes ignores it by construction. Second, the hole is bigger than 4 analysis pixels. Both are intentional refusal cases, not bugs. If your masks are genuinely ragged rather than pinholey, this node is the wrong tool; clean them where they're generated.
Resolution matters. "4 pixels" is in the mask's own pixel space, and the batch you get is at whatever resolution the review stored (review['shape']). A hole that's 4 px on a 4K frame is invisible; the same rule on a 512px crop is generous. Expect behaviour to change with input size.
It's a v1.0.11 node, and v1.0.11 nodes are a family. The 1.0.11 release added a batch of interlocking nodes - this one, DOGMACategories8V111, DOGMAChooseCategoriesV111, DOGMAAllSamplerSelectV111, the 1.0.11 reviewers. They're designed to sit in one pipeline. You can use this one with a v1.0.10 review object (the bundle shape is the same), but don't expect the node IDs to be interchangeable in a saved workflow.
Install
Manager → search DOGMA Nodes (publisher axior), or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI
requirements.txt declares scipy>=1.10 - this node is the reason (SciPy is imported right here for ndimage), so if you half-install the pack by copying files instead of pip-installing, this is the node that dies with an import error. The pack downloads no models and patches no ComfyUI internals.
Blunt version of the caveat that applies to the whole pack: it's a single-author pipeline (axior's DOGMA restoration workflow) published as nodes, validated on CPU with mocked model calls, and it has no footprint in the community discussion corpus I can find. That's fine for a 60-line mask cleanup - the logic is readable and the report tells you what it did. It would be less fine if it were doing something you couldn't inspect.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| review | DOGMA_REVIEW | — | |
| clean_micro_holes | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| approved_instances | MASK | — |
| report | STRING | — |