SamplingSizeDetailerHookProvider
Stop Guessing guide_size — Sample Every Crop at a Real Resolution
- DETAILER_HOOK
The whole point of a detailer is that the cropped region gets resampled at a size the model can actually work with. The usual controls for that, guide_size and max_size, are a bit of a blunt instrument: you pick a number, the detailer upscales each crop to it as best it can, and every crop ends up at some arbitrary aspect ratio that isn't any of the buckets your model was trained on. SamplingSizeDetailerHookProvider replaces that with a list of resolutions and a rule: each crop gets sampled at the resolution from your list whose aspect ratio is closest to it.
How it decides
The hook is called for each detected area before the detailer samples it, and it does two things.
First, it picks the nearest shape. Closest is measured as aspect-ratio distortion - for each candidate resolution it compares candidate height × crop width against candidate width × crop height and takes the one that stretches least. So a wide crop finds your widest bucket and a tall crop finds your tallest one.
Second, it reshapes the crop region to match that ratio exactly. The region grows on its short side to hit the target aspect. If the image edge stops it, the other side shrinks instead - but never below the bbox, so you can't end up cropping the subject out. Then, because the hook also reports the chosen size back to the detailer, that's the resolution the crop is actually sampled at.
The result is that guide_size and max_size no longer set the sampling size at all. They still get a vote on whether a segment is processed: without force_inpaint they decide which detections are skipped for being too small. That's worth saying twice, because "I set the hook and now nothing gets detailed" is almost always a guide_size fight rather than a hook problem.
The one input
resolutions - a multiline string of WIDTHxHEIGHT entries, separated by newlines, spaces or commas. The default is an SDXL bucket set:
1024x1024
1152x896
896x1152
1216x832
832x1216
1344x768
768x1344
1536x640
640x1536
Put a single entry in and every crop is sampled at exactly that size, which is how you force a fixed grid - handy for comparing detail passes across seeds, or for Core ML-style constraints where the model only accepts a few shapes. Put in your model's own bucket set if you're not on SDXL; SD1.5-style 512 buckets, or whatever the model card lists for the newer architectures. The README mentions a preset that fills in a known set for a given model family; if your ComfyUI doesn't show that widget, the text box is the whole story - paste the list in yourself and it behaves identically.
Bad entries fail loudly rather than silently: anything that isn't NNNxNNN raises an error naming the offending token, and an empty list raises its own error. So if you're generating the string from somewhere, mind the separators - they can be newlines, spaces or commas, but not semicolons.
Wiring it up
Output is a single DETAILER_HOOK.
FaceDetailer: connect it there once. FaceDetailer runs detection and refinement internally, so one connection covers both.- Split detector →
Detailer (SEGS)graphs: connect it to both the detector and the detailer, or give the SEGS their crop regions withApply Crop Region Hook (SEGS). This isn't the pack being fussy: the crop region and the sampling size are decided in different places, and the two halves each need the hook to see it. Miss the detector and your crops keep their old shape; miss the detailer and the resolution never gets applied.
Combining hooks? DetailerHookCombine, first then second. Since this hook rewrites crop regions, think about order - a CropRegionMultipleDetailerHookProvider after it will round the sizes you just carefully matched.
Install
Ships with Impact Pack, category ImpactPack/Detailer.
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. Restart after. Manager users search ComfyUI Impact Pack. First run creates impact-pack.ini in the pack folder and downloads the default SAM checkpoint into models/sams; drop an empty file named skip_download_model in custom_nodes to avoid that download.
The honest opinion
This is the hook I'd reach for first on a detailer that's producing soft or slightly-wrong faces. Fixing the sampling resolution to a bucket your model was trained on does more for output quality than nudging denoise, and it makes runs repeatable in a way that guide_size doesn't.
What it won't do is decide anything for you. If your list is a pile of 1024-ish buckets and you're detailing 90-pixel faces, you're not gaining detail, you're inventing it - detailers upscale and re-diffuse, they don't recover information that was never captured. Same caveat as every detail pass in Impact Pack.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| resolutions | STRING | 1024x1024 1152x896 896x1152 1216x832 832x1216 1344x768 768x1344 1536x640 640x1536 | Resolutions as WIDTHxHEIGHT, separated by new lines, spaces or commas. With one resolution, every crop region is sampled at it. The preset widget below fills in a set of them. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DETAILER_HOOK | DETAILER_HOOK | — |