Nodes/CMK Flow/CMK Smart Detailer
ComfyUI Node

CMK Smart Detailer

Detect, crop, resample, paste back — without installing Impact Pack

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK Smart Detailer
  • image
  • basic_pipe
  • sam_model_opt
  • image
  • segs_detected
  • segs_detailed
  • detailer_log
  • enabled
  • diagnostic
◄boolean_detailer_enabletrue►
◄enabletrue►
◄model_name▾►
◄bbox_threshold0.50►
◄bbox_dilation0►
◄crop_factor3.0►
◄drop_size10►
◄guide_size512►
◄guide_size_fortrue►
◄max_size768►
◄seed0►
◄steps20►
◄cfg8.00►
◄sampler_name▾►
◄scheduler▾►
◄denoise0.50►
◄noise_masktrue►
◄force_inpainttrue►

A face occupying 80×80 pixels of a 1024×1024 frame gets 80×80 worth of model attention and comes out mangled. The fix has been the same since ADetailer: find the region, crop it, run a fresh sampling pass at proper resolution, composite it back. In ComfyUI that loop is Impact Pack's FaceDetailer, and for years the answer to "how do I do this" was "install Impact Pack". CMK Smart Detailer is the same loop running on CMK's own engine - YOLO detection, native pasteback, and a BASIC_PIPE for the model instead of a foreign pack's socket types.

How the loop actually runs here

Detection goes through Ultralytics with models from ComfyUI's ultralytics_bbox and ultralytics_segm folders - the same paths Impact Pack uses, so any face_yolov8 weights you already have work as-is. The detector takes a confidence bbox_threshold (0.5), dilates the box by bbox_dilation pixels, expands it by crop_factor (3.0, i.e. three times the box size to give the sampler context), and drops anything smaller than drop_size (10 px).

Then, per detected region: the crop is resized so the short side reaches guide_size (512 by default), unless guide_size_for is off, in which case the crop region's short side is the basis instead. The long side is capped at max_size (768) and everything is rounded to a multiple of 8. That crop is VAE-encoded, optionally given a noise_mask from the segment's own mask, sampled with your steps/cfg/sampler_name/scheduler at denoise (0.5 default, hard-capped at 0.5), decoded, and resized back into the original crop rectangle. Each crop's seed is seed + index, so regions stay stable between runs. Finally the refined crops are pasted back with a feathered soft mask - SEGSPaste at feather 5, alpha 255.

Inputs and outputs

  • image and basic_pipe - the pipe is a 5-tuple of model, clip, vae, positive and negative conditioning. If you're inside a CMK Flow chain you don't build it by hand; CMK Detailer Prepare -Pipe- produces a DETAILER pipe and CMK Pipe Peek Detailer peels the basic_pipe off it.

And that pipe is exactly what Impact Pack's BasicPipe node emits, so this detailer also drops into a non-CMK graph where you already have one lying around.

  • boolean_detailer_enable (global) and enable (local) both have to be on for anything to happen. Off means passthrough, not an error.
  • model_name, bbox_threshold, crop_factor, denoise, seed, steps, cfg are the ones you'll actually adjust. crop_factor at 3 and denoise around 0.3–0.4 is where most people land; 0.5 is already a strong reinterpretation of the region.

Outputs: image (the composited result), segs_detected, segs_detailed, detailer_log (a string - handy for knowing what it found), enabled, and diagnostic.

Installing

Manager: search CMK Flow → install the CMKFlow entry → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/CMKFlow/cmk_nodes.git cmk_nodes
python3 cmk_nodes/scripts/install_cmk_requirements.py
python3 cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/shared/models"

The resource script installs the Ultralytics detectors, SAM models and InsightFace buffalo_l directly, which saves hunting for YOLO weights. CMK needs Vue Nodes / Nodes 2.0 enabled.

Things that will annoy you

No detections is the most common outcome, and it's usually bbox_threshold too high or a detector that doesn't match your subject - a face model won't find hands, and a generic object model won't find small faces. The detailer_log output tells you what happened, so read it instead of re-rendering blindly.

Second, the honest one from the ongoing detailing debate: if the face is already large in frame, a second pass changes it without improving it. The most-upvoted reaction to a widely shared video detailing demo was that the two versions looked identical. Detailing earns its keep on the small stuff.

Third, a footnote worth knowing if you pin dependencies for anything you ship: the Ultralytics package is the route by which a December 2024 supply-chain compromise - a cryptominer in a released version of the package - reached ComfyUI users through Impact Pack. CMK requires ultralytics too. That's not a CMK bug, just a reminder that this particular dependency has history and a version pin is a reasonable precaution.

CategoryCMK/Toolbox/Image

Inputs (21)

NameTypeDefaultDescription
imageIMAGE—
basic_pipeBASIC_PIPE—
boolean_detailer_enableBOOLEANtrue—
enableBOOLEANtrue—
model_nameCOMBO0 options:
bbox_thresholdFLOAT0.500–1—
bbox_dilationINT0-512–512—
crop_factorFLOAT3.01–100—
drop_sizeINT101–8192—
guide_sizeFLOAT51264–8192—
guide_size_forBOOLEANtrue—
max_sizeFLOAT76864–8192—
seedINT00–18446744073709550000—
stepsINT201–10000—
cfgFLOAT8.000–100—
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
denoiseFLOAT0.500.0001–0.5—
noise_maskBOOLEANtrue—
force_inpaintBOOLEANtrue—
sam_model_optoptSAM_MODEL—

Outputs (6)

NameTypeDescription
imageIMAGE—
segs_detectedSEGS—
segs_detailedSEGS—
detailer_logSTRING—
enabledBOOLEAN—
diagnosticCMK_DIAGNOSTIC—