DOGMA v37 SAM Input Resize
Stop feeding your 5K master to the segmenter
- image
- image
- info
Segmentation is the cheap part of a detailing pipeline, and people treat it as if it were free. It isn't - a ViT-based segmenter over a 4K-plus image is a real VRAM spike, and on a six-category pass that spike happens six times. DOGMA v37 SAM Input Resize is the cap that keeps that bill bounded.
What it does
One job: if the image's longest side is bigger than max_side, downscale proportionally so the long side equals max_side; otherwise pass it through untouched. It never upscales.
The mechanics are worth spelling out because they're the pack's house style. The scale factor is applied to both dimensions, then each is rounded to the nearest multiple of 16 (minimum 16), and the resize is bilinear with antialiasing on. The image also gets clipped to three channels. The info output tells you which branch happened: SAM source kept WxH or SAM source WxH -> NWxNH.
max_side is an INT, default 2560, range 1024–4096 in steps of 64. The default matters: 2560 is above the native resolution most segmentation checkpoints were trained at, so on a normal 2K master this node does nothing at all. It's a guard rail, not a resize you should expect to see fire.
Inputs and outputs
image in, image + info out. That's all - no mask output, no scale factor to reuse. Which is exactly why DOGMAResizeMaskToImageV15 sits downstream in the reference graph: the mask comes back at the reduced size, and something has to conform it to the full-resolution master before it drives a stitch.
The broader picture: SAM 3 is the current default for text-prompted masking in ComfyUI, and it's the natural partner for the DOGMA planners, which emit concept phrases like car, automobile, sedan, hatchback, station wagon. You don't need this node if you run SAM at modest resolutions; you need it the moment your master is a 4K upscale and your 12–16GB card starts thrashing. The sibling node DOGMAV50SAMInputGate exists for the heavier case where the master is so big the SAM pass has to be tiled.
The trade you're making
Downscale the input and the mask comes back softer. You lose a couple of pixels of edge precision, and after it's resized back up, a 0.5 threshold lands slightly differently - small objects can grow or vanish. For a semantic region mask that then gets feathered anyway, nobody will see it. For a tight object cutout, it matters.
So the honest guidance: if you have headroom, leave max_side at 2560 and let it pass everything through; the multi-category pass is where the savings come from, not the single-mask case. If you're dropping it to 1024 to survive on an 8GB card, expect masks that are right about where and fuzzy about exactly.
Install
Manager → search DOGMA Nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
This node has no dependencies and no models of its own - the pack's requirements.txt declares nothing. The segmenter is a separate install: ComfyUI's native SAM 3 support or one of the community SAM 3 node packs. Be aware that some of those pull Triton, which is a genuine obstacle on Windows; if SAM itself won't load, this node is not the culprit.
Who made the pack: DOGMA Nodes is axior's, the studio half of a Milan production team that runs commercial AI work through heavy ComfyUI masking chains - which is why a boring "cap the input size" utility exists at all. It's the kind of node you write after watching VRAM accumulate across six segmentation passes one too many times.
Gotcha
The threshold is the longest side, both orientations. A 4000x1500 panorama and a 1500x4000 portrait both trigger at the same max_side, and both lose the same proportion. Nothing breaks; just don't expect this to preserve pixel dimensions you were counting on. Read info if you need to know what actually happened - it's a one-line answer and it's never wrong.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| max_side | INT | 25601024–4096 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |