Nodes/DOGMA Nodes/DOGMA V50 2K Region Crops
ComfyUI Node

DOGMA V50 2K Region Crops

Every instance crop the same 2K before Klein sees it — that's the V50 trick

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA V50 2K Region Crops
  • image
  • masks
  • crops
  • crop_masks
  • stitch
  • info
category
kind
target_long_side2048

Per-instance regional restoration has an awkward property nobody talks about: crop sizes are wildly inconsistent. A bus gives you a 1792px crop, a distant pedestrian gives you 300px, and both get sampled by the same model at whatever denoise your pipeline picked. The small one comes back mushy because it wasn't given enough pixels or enough steps to behave like the big one.

V50's answer: normalise every active crop to the same long side before the model touches it.

Where the crops come from

This node is a subclass of the pack's region-crop node, so the first half is inherited behaviour worth understanding. Given a masks batch (per-instance SAM output) and a category / kind, it:

  • For OBJECT categories (cars, bus, trucks, people, everything else), finds connected components in each mask, dedupes boxes at 0.72 IoU, then greedily clusters nearby instances into groups - cars cap at 3 per group and 28 groups, people at 4 and 24 - using a per-category gap threshold and crop context. The docstring is explicit that it preserves "small/distant" instances rather than dropping them, which is the correct bias for a detail pass: comp_thr drops to 0.10 for cars/bus/trucks/people.
  • For STRUCTURE and SURFACE kinds, it uses a different branch again - true connected regions, never a grid, as the source comment insists.
  • Crops carry context pixels around the group bbox, and each gets a mask reconstructed as the union of its member instances, so a crop containing three cars doesn't get asked to restore the space between them.
  • If nothing valid is found it returns a no-op meta - a small centred crop with a zero mask flagged noop: True, which the stitch side skips. Nothing errors; a category that found nothing simply contributes nothing.

The masking logic is the same pattern the KB's detailing doc describes for Impact Pack-style workflows (detect → crop → re-render → paste) - except here it's VLM-named categories and SAM masks instead of YOLO models, which is the promptable-masking route the same doc covers.

What V50 adds

After the parent returns, every non-noop crop's long side is forced to target_long_side - 2048 by default, snapped to a 16px multiple, image resampled bicubic with antialiasing, mask bilinear. That can be an upscale (small instance crops) or a downscale (the parent's own per-category caps of 1664 for cars, 1792 for buses, 1536 for people). Either way, every crop that reaches the sampler is 2K on its long side, so one denoise value, one step count and one prompt style behave predictably across the batch. The noop crops are deliberately left alone.

Outputs are crops, crop_masks, stitch - all lists, for list-mode consumers - plus info, which reports the plan line from the parent and then how many crops were forced to the target.

Inputs

image, masks, category (STRING, forced), kind (STRING, forced), and target_long_side (default 2048, 512–4096, step 64). Only that last one is a decision you make here, and 2048 is a good default for a 4-step distilled editor on a 16GB-plus card.

Install

ComfyUI Manager → search DOGMA Nodes, or:

cd ComfyUI/custom_nodes && git clone https://github.com/axior/ComfyUI-DOGMA-Nodes

Restart. No pip dependencies - requirements.txt is # No external dependencies. - and no model files, though the pipeline this belongs to assumes a Klein checkpoint and a VLM from other packs. The README doesn't document it; the semantic suite registers itself from dogma_semantic_v5641.py.

Where it bites

Forcing crops up to 2K doesn't create detail - it gives the model a consistent working size, nothing more. A 300px pedestrian blown to 2048 is still a 300px pedestrian's worth of information; you'll get smooth plausibility, not new faces. If you need real resolution on tiny instances, the answer is a better master, not a bigger crop.

Category drives the crop geometry. The category string is canonicalised to decide clustering behaviour and per-category caps - a typo'd or unexpected category falls through to the generic defaults, and you get cars clustered like furniture.

Nothing above 2K stays above 2K. The parent's 1664/1792/1536 targets exist to keep the pass fast; the long-side enforcement is downstream of that, so the net effect is "everything becomes 2048", including things the parent deliberately shrank. If you want natives preserved, raise target_long_side toward 4096 and accept the VRAM bill.

Watch the stitch metas. Everything downstream of a list-mode crop node has to be list-mode, and the noop flag is the contract that keeps empty categories out of your composite. A stitch node that ignores it will paste a zero-masked centre crop over your master and you'll spend an afternoon wondering why one tile went soft.

CategoryDOGMA/v50

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
masksMASK
categorySTRING
kindSTRING
target_long_sideINT2048512–4096

Outputs (4)

NameTypeDescription
cropsIMAGE
crop_masksMASK
stitchDOGMA_STITCH
infoSTRING