Nodes/ComfyUI-LukutarNodes/SEGS Set Crop Size
ComfyUI Node

SEGS Set Crop Size

SEGS Set Crop Size

By Mistress-Lukutar·Created 7 days ago·Updated 2 days ago· 1
SEGS Set Crop Size
  • segs
  • SEGS
width512
height512
modeexact
round_to8

Somewhere between "the detector found a face" and "the detailer re-rendered it nicely," there's a step that most people never look at: how big is the crop, actually? In Impact Pack, the detector's crop_factor is relative - it scales with the detection. The same factor that gives you 128×128 on a small face hands you 1024×1024 on a large one, and plenty of detections land on genuinely awkward sizes like 552×239. Feeding a sampler a weird non-square crop at inconsistent resolutions is how you get detail passes that look soft or shift the region's look between frames.

SEGS Set Crop Size exists to make that choice explicit. It refits every segment's crop region to an absolute target size - 512×512 is the default - so every detected region gets processed at a resolution you chose, not one the detector happened to produce.

How it works

The node rewrites each segment's crop_region, leaving the bbox, label, confidence, and mask content untouched. The crop rectangle is re-centered on the bbox center and kept inside the image; the cropped mask is re-cut into the new region, zero-filling the added context area exactly like Impact's own crop padding, and any cached cropped_image is dropped so consumers re-crop from the source.

The mode dropdown is where you decide what "fit" means:

  • exact (default) - the crop region is exactly width×height, centered on the bbox. One caveat: if the bbox itself is larger than the target, the region grows just enough to contain it (rounded up to round_to multiples), so a detection is never cut off - the size ends up larger than requested and the node logs a warning. Nobody wants a face chopped at the edge of its crop.
  • aspect - the bbox is scaled uniformly around its center so its longer side equals max(width, height). Proportions are kept and sizes round up to round_to multiples: the README's example is 400×173 @ 512 → 512×224. It never scales below 1×, so the bbox always fits.

round_to (default 8) rounds fitted sizes up to multiples of 8 - the SD-friendly alignment you already think in. It applies to aspect-mode sizes and to bbox-forced growth; the exact-mode target is used verbatim.

Inputs and output

segs (from an Impact Pack detector like SEGM Detector (SEGS)), width and height (defaults 512×512, stepped in 8s), mode, round_to. Output is a single SEGS with refitted crop regions. Because the bbox and mask content are unchanged, the node sits cleanly between a detector and a Detailer pipeline - insert it, and the Detailer's crop math changes without the detection changing.

Installation

Part of ComfyUI-LukutarNodes (MIT). ComfyUI Manager: Custom Nodes Manager → Install via git URLhttps://github.com/Mistress-Lukutar/ComfyUI-LukutarNodes, or:

cd <ComfyUI>/custom_nodes
git clone https://github.com/Mistress-Lukutar/ComfyUI-LukutarNodes

Restart ComfyUI. Only extra runtime dependency is opencv-python (>= 4.8); Manager installs requirements.txt, manual installs may need pip install opencv-python. No models, no keys. You need Impact Pack (or any SEGS producer) upstream to have SEGS to fit. Category Lukutar/Image.

Common issues

  • The region grew beyond your target - that's the exact mode's bbox-larger-than-target case, and it's a warning, not an error. If you're seeing it, your detections are big relative to the target; either raise width/height or switch to aspect.
  • Regions clamped to the image - a target larger than the image is clamped to the image size with a warning. You can't crop a 1024 target out of a 512 image, and the node tells you instead of silently producing garbage.
  • Empty SEGS passes through untouched - same behavior as the rest of the SEGS family; no crash, just nothing to fit.
  • Young pack (v0.10.x, 2026), minimal community footprint - the README and the tested core/ code are your best references.
CategoryLukutar/Image

Inputs (5)

NameTypeDefaultDescription
segsSEGSSegments from an Impact Pack detector, e.g. SEGM Detector (SEGS)
widthINT5128–16384Target crop width in pixels
heightINT5128–16384Target crop height in pixels
modeCOMBOexactexact: crop exactly width x height (grown only if the bbox is larger); aspect: scale the bbox uniformly so its longer side equals max(width, height)
round_toINT81–128Round fitted sizes up to multiples of this (SD-friendly 8); the exact-mode target is used verbatim

Outputs (1)

NameTypeDescription
SEGSSEGS