Nodes/DOGMA Nodes/DOGMA Phase3Crops 1.0.22
ComfyUI Node

DOGMA Phase3Crops 1.0.22

Native-resolution crops, one object at a time, with denoise attached

By axior·Created 6 months ago·Updated 2 days ago· 2
DOGMA Phase3Crops 1.0.22
  • selection
  • crop_jobs
  • selected_masks_after_ownership
  • crop_geometry_and_time
◄overlap_policy▾►
◄target_long_side2048►
◄group_gap_px180►
◄context_px160►
◄max_objects_per_chunk1►
◄max_chunks_per_category24►
◄max_total_crops48►

Cutting a region out of a photo so you can re-render it at full resolution is the oldest trick in the detailer playbook, and it is also where most homemade pipelines quietly go wrong. Crop the wrong padding and the model invents a new border. Merge two adjacent detections into one crop and the model treats two separate objects as one thing and averages them. Blow through the crop budget on the first category and later ones render nothing at all.

Phase3Crops is the node that handles all of that. It takes the selection from the category chooser - the bundle with masks, target IDs, and a denoise value per target - works out the ownership of overlapping detections, and emits a list of crop jobs. Each job is one independent object with its crop image, an inpaint mask, a blend mask, geometry to paste it back with, and its own denoise.

How it works

Ownership first. Cross-category overlap is resolved by the smaller_regions_first policy: categories are ordered by total mask area and each one claims its pixels against a running occupied map, so a big background category cannot swallow a small object that sits on top of it. Overlap within a category gets the same isolation, instance by instance, largest first. The report prints how many pixels moved and, usefully, the pack states plainly that this is geometry, not semantics - a clean overlap result says nothing about whether SAM found the right thing.

Then crops. Every selected category is classified as an object or a continuous surface, and each surviving instance gets a native-resolution crop: the object's bounding box expanded by context_px of surrounding photo, scaled to target_long_side only if it does not already fit, padded to a multiple of 32, with the mask interpolated alongside it. The noise mask and the blend mask are both confined to the owning object's silhouette, so a re-render cannot bleed into a neighbour.

Budgets are explicit and never silently merged. max_chunks_per_category and max_total_crops spread the remaining allowance across the categories still to come, and anything that does not fit is reported as DEFERRED - with no caption call. That string is your signal to raise the budget, not a bug.

Inputs that matter

  • selection (DOGMA_CATEGORIES) - straight from a chooser. This node reads denoise_by_target off it and stamps those values into the jobs.
  • context_px (160) - how much surrounding photo each crop carries. Too tight and the model has no context to blend with; too generous and you are paying for pixels you will throw away. This is the single most useful knob here.
  • target_long_side (2048) - the resolution budget per crop.
  • group_gap_px (180), max_objects_per_chunk (fixed at 1), max_chunks_per_category (24), max_total_crops (48) - the grouping and budget controls.
  • overlap_policy - only smaller_regions_first is accepted; the node raises on anything else.

Outputs: crop_jobs (DOGMA_PREP_CROPS, into a describe/render stage), selected_masks_after_ownership (IMAGE - a visual of what survived ownership, worth looking at), and crop_geometry_and_time (STRING).

Install

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

Or ComfyUI Manager → DOGMA Nodes, then restart ComfyUI. Only scipy>=1.10 ships in requirements.txt.

Where people get burned

Version skew. This node insists the selection carry denoise_by_target. Pair it with the 1.0.22 or 1.0.24 chooser and it works. Pair it with the older V111 chooser and you get a KeyError.

Assuming the crops are the masks. They are not: selected_masks_after_ownership is a preview of ownership, and the per-job masks live inside the bundle. If you want to see the actual inpaint and blend masks per crop, that is what the review output of the 1.0.23 render line is for.

Budget exhaustion dressed up as "nothing happened." Read crop_geometry_and_time. DEFERRED lines mean the budget ran out; the renderer will simply not touch those regions.

CategoryDOGMA/v1.0.22

Inputs (8)

NameTypeDefaultDescription
selectionDOGMA_CATEGORIES—
overlap_policyCOMBO1 options: smaller_regions_first
target_long_sideINT2048512–4096—
group_gap_pxINT1800–1200—
context_pxINT16032–640—
max_objects_per_chunkINT11–1—
max_chunks_per_categoryINT241–24—
max_total_cropsINT481–96—

Outputs (3)

NameTypeDescription
crop_jobsDOGMA_PREP_CROPS—
selected_masks_after_ownershipIMAGE—
crop_geometry_and_timeSTRING—