Nodes/DOGMA Nodes/DOGMA v37 Category Grouped Crops
ComfyUI Node

DOGMA v37 Category Grouped Crops

Crops by family, straight from a mask and a dropdown

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA v37 Category Grouped Crops
  • image
  • mask
  • crops
  • crop_masks
  • stitch
  • info
family
max_groups8
context_px160
target_long_side1792

Most of this pack assumes you've wired a vision model to write a scene plan. DOGMACategoryGroupedCropsV37 is the one you can use today, on its own, with nothing but a mask and a dropdown - and it's the version I'd point a beginner at first, because it teaches you the geometry of the crop step without any VLM in the way.

What you give it

image, mask, family, max_groups (default 8), context_px (default 160), target_long_side (default 1792). Outputs: crops, crop_masks, stitch, info.

The family dropdown is the whole idea, and it's pleasingly literal: vehicles, people, architecture, vegetation, street_objects, road_ground. Pick the one your mask is about, because the family decides how the regions get chunked.

The mechanism

It takes your mask (multiple channels get max-merged into one), grows it slightly with a 17px max-pool so the whole object is inside the crop rather than just its centre, then drops to a coarse 128px occupancy grid and runs a flood-fill over occupied cells. Each connected blob becomes a bounding box, expanded by context_px on every side.

Then the family matters. Regions of architecture, vegetation or road_ground that are larger than 1.35 × target_long_side get split into overlapping windows on a stride of ~0.80 × target, and each window is kept only if the mask still has content in it (mean > 0.01). The other families don't get split at all - a car or a person stays whole no matter how big the box is. Finally each crop is downscaled if needed so its long side fits target_long_side, on a 16-pixel grid.

That's a clean division of labour and it matches how detail passes actually fail: splitting a pedestrian across two tiles produces two half-people, while a 4000-pixel facade in one crop produces a model that has to invent an entire building's worth of detail at 0.25x scale.

context_px is the anti-seam knob, and 160 is a reasonable default. Too little and the model has no idea what surrounds the object; too much and the object is a rounding error in its own crop.

Wiring

crops into the masked local pass; stitch and crop_masks into the stitch node (DOGMAOpaqueMaskedStitchV37 is the matching one) so only the edited pixels land back. reference_crops isn't in this node's output list - if you want the clean source cropped to the same geometry, that's DOGMAAdaptiveCropsV39; V37 is the simpler one-mask-in, crops-out tool.

Where this beats wiring a planner: whenever you already know the family. Small repair jobs, a single-sector workflow you're iterating on, or bootstrapping the geometry before you add the VLM stage. Where it loses: it can't tell a car from a person, and it never says "don't touch that".

Install

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

Or Manager → DOGMA Nodes, restart. Zero Python dependencies - requirements.txt is a comment, pyproject declares none - so the only setup friction is the models (a segmenter, and whatever does your local re-render). The README doesn't document this node.

Common issues

One crop containing the entire mask. You picked a non-broad family and gave it a huge blob. The chunking only kicks in for architecture/vegetation/road_ground, deliberately.

"no selected regions" in info. Your mask is empty. The node returns a 64px placeholder crop with a zero mask instead of erroring, which keeps the graph alive and means the failure shows up as "nothing happened" rather than a stack trace.

Everything is 1792px on the long side and slow. target_long_side is a target, not a cap - if a crop is smaller than it, it gets upscaled. Source regions that are already 100px wide blown to 1792 is where detail passes get mushy; feed it bigger crops or lower the target.

Objects cut off at the crop edge. Your mask is tight on the object and context_px isn't covering the extremities. 160 is a floor for vehicles, not a comfortable value.

CategoryDOGMA/Semantic Detailer

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
maskMASK
familyCOMBO6 options: vehicles, people, architecture, vegetation, street_objects, road_ground
max_groupsINT81–16
context_pxINT16032–512
target_long_sideINT1792768–3072

Outputs (4)

NameTypeDescription
cropsIMAGE
crop_masksMASK
stitchDOGMA_STITCH
infoSTRING