CropRegionMultipleDetailerHookProvider
Crop Regions That Are Multiples of 64, So Tiles and Models Stop Complaining
- DETAILER_HOOK
Detectors produce crop regions at whatever size the box and the crop factor happen to give - 337×211, 528×403, whatever. Latent-space models would much rather work in neat multiples of 8, and a pile of experiments (tiled sampling, tile ControlNets, fixed-bucket test grids) really want a bigger nicety like 64. This hook rounds every crop region up to a multiple you choose.
The mechanism
One integer, multiple, default 64. For each crop region, the hook rounds each side up to the next multiple of that number and grows the region by half the difference on each side, so the subject stays centred. Clamped to the image, obviously.
There are two behaviours worth knowing, both straight from the node's own description. First, growth stays inside the image - a region near the edge shifts rather than extends past the frame. Second, where the image is too small to hold the grown size, the region takes the largest multiple that fits, and if a whole side of the image is shorter than multiple, that side is left as it is. So you never get a region that's bigger than the picture, which is the failure a naive round-up would give you.
The practical target: the tiles from Make Tile SEGS. Tile-based detail/upscale pipelines want consistent, aligned, divisible-by-64 regions so tiles line up and the sampler doesn't pad or crop behind your back. Because Make Tile SEGS doesn't take a detailer_hook, that combination needs Apply Crop Region Hook (SEGS) in between - the pack's own README calls out exactly this pairing.
multiple steps in 8s between 8 and 1024. 64 is the sensible default; 128 if you're doing heavy tile work and have the VRAM; drop to 8 if you're on SD1.5 shape constraints and just want latent-friendly numbers. There's no reason to go below 8 - latents are 8-pixel blocks, so smaller multiples round to the same thing.
Inputs and outputs
multiple(INT, default 64, 8–1024, step 8) - the width and height of each crop region become a multiple of this.- Output:
DETAILER_HOOK.
Where does it go? Anywhere a hook is accepted and crop regions are decided. In a one-node graph, that's FaceDetailer's detailer_hook. In a split graph, BBOX Detector (SEGS) takes the hook and the SEGS carry the rounded region downstream into Detailer (SEGS). For SEGS that no detector made, put Apply Crop Region Hook (SEGS) between the SEGS producer and whatever consumes the crop region - and note its own advice, that it belongs before ControlNetApply (SEGS), since that node crops its control image using the crop region the SEG currently has. Round after that and your ControlNet is working on a different framing than the detailer.
Need more than one hook effect? DetailerHookCombine chains two, first then second.
Install
Impact Pack ships this node under ImpactPack/Detailer; there's nothing else to fetch.
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt
Windows portable: ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt. Then restart. ComfyUI Manager users can search ComfyUI Impact Pack and skip the terminal entirely - which is the recommended route in the pack's own README. First launch creates impact-pack.ini and downloads a default SAM checkpoint into models/sams; create an empty file named skip_download_model in custom_nodes to skip that download.
Worth knowing while you're in the install: since v8.0 the Ultralytics detector provider moved to a separate Impact Subpack and is no longer installed automatically. This hook needs no detector of its own, but if you were planning to feed it BBOX Detector (SEGS) from a YOLO model, that's a second install.
Troubleshooting
If the crop regions look like they grew but your output didn't change, you probably attached the hook to the detailer instead of the detector. The crop region is decided before the detailer ever runs; a hook on Detailer (SEGS) can't retroactively shrink or round SEGS that arrived with a region already set. Use Apply Crop Region Hook (SEGS), or hook the detector.
Second: rounding up means bigger crops, and bigger crops can flip segments from "skipped" to "processed" or vice versa in ways you didn't ask for, because guide_size comparisons happen against the region the detailer is handed. If a run suddenly got slower or a small face suddenly started being refined, that's why - adjust guide_size to compensate.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| multiple | INT | 648–1024 | The width and the height of each crop region become a multiple of this size. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DETAILER_HOOK | DETAILER_HOOK | — |