DOGMA SAMCoherentSearch v1.0.9
Box-prompted SAM masks, and why the pack walked it back
- image
- model
- clip
- previous
- candidates
- search_report
This node is a piece of the pack's history, and knowing that saves you from a bad afternoon. It's the 1.0.9 attempt at "make text-prompted SAM return coherent objects instead of soup," and the next two releases explain, in the author's own changelog, why that instinct was mostly wrong.
Still - it's the right tool in one specific situation, and the mechanism is genuinely interesting.
How it works
Two-stage per category. First it runs text-conditioned SAM 3 detections through the pack's shared search machinery, over either the whole image (global) or overlapping 64%-size recovery windows (local_recovery, which needs a previous review to work from). Then, for each detector box it keeps, it does something different from every other search node in the pack: it re-decodes the object with a box-only SAM pass on a contextual crop, padded by 12% so SAM has surrounding context, and it does not OR the result with the raw text-detector mask.
That box-only decode is the 1.0.9 idea: text-conditioned SAM tends to union its refined passes with a coarse mask, which is exactly how you end up with a blob that includes the wall behind the sign. A single box-prompted decode gives you the thing inside the box.
Then geometry filters the results, hard:
- a selection leaking more than 20% outside its detector box (with 2% tolerance) is rejected;
- a fragmented selection whose largest component is under 45% of the mask is rejected;
- a sparse outline is rejected by fill ratio - a minimum of 7% coverage of the box, or 0.8% for thin categories like fences, railings, wires, branches and vegetation;
- tiny islands under 0.3% of the largest component are dropped, with no closing, dilation or hole filling, so arches and occlusions survive;
- boxes whose mask would add less than 10% new pixels (because something already approved covers them) are skipped without spending a decode.
Budgets are explicit and reserved: max_instances is the total decoder-attempt budget per category, recovery_views reserves attempts for a later recovery pass so a partial success doesn't lock you out of fixing the gaps.
The inputs and outputs
image,model,clip- one source image (a batch raises), plus the SAM 3 model and the text encoder for the query.categoryandquery_hint- the category name and the noun list your planner produced; queries are built from the hint first, then the pack's built-in aliases.mode,threshold,max_instances,max_queries,recovery_views- the search shape. For local recovery you also wireprevious, theDOGMA_REVIEWfrom the first pass; if the category or image geometry don't match it, the node refuses rather than mixing generations.candidates(DOGMA_CANDIDATES) → the audit node, thenDOGMAInstanceReviewV109, thenDOGMAFinalMasksV109.search_report(STRING) - detections, decodes, budget used, candidates. Always read the budget line; it tells you when a category hit the cap and everything else just stayed unsearched.
Install
Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Restart. scipy>=1.10 is the only pip dependency, and it's real here - the island removal uses ndimage. You also need a ComfyUI with SAM 3 box-prompt support (SAM3_Detect); on Windows that path wants Triton, which is where most SAM 3 installation pain lives.
Should you use it?
Usually no. The 1.0.10 changelog is unusually candid about 1.0.9: it changed the decoder and added restrictive shape filters, so its coverage failures "cannot isolate a single factor," and 1.0.10 removed both - restoring text conditioning with four refinement passes and dropping density/dominant-component rejection. The 1.0.11 notes add that the pack has not gone back to "the failed 1.0.9 box-only decoder."
Reach for this node when your problem is the opposite of coverage: text SAM is handing you masks that swallow the background, and you'd rather have a tighter object inside a detector box than a generous blob. When your complaint is "it keeps missing things," DOGMASAMCoverage v1.0.10 or the lazy v1.0.11 variant is what you want. Either way, load the workflow generation this node belongs to - the pack keeps versioned IDs precisely so you don't mix a 1.0.9 search with 1.0.11 audit expectations.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | MODEL | — | |
| clip | CLIP | — | |
| category | STRING | — | |
| query_hint | STRING | — | |
| mode | COMBO | 2 options: global, local_recovery | |
| threshold | FLOAT | 0.250.05–0.9 | — |
| max_instances | INT | 82–32 | — |
| max_queries | INT | 31–4 | — |
| recovery_views | INT | 20–4 | — |
| previousopt | DOGMA_REVIEW | — | |
| afteropt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| candidates | DOGMA_CANDIDATES | — |
| search_report | STRING | — |