Nodes/CMK Flow/CMK Detailer Prepare -Pipe-
ComfyUI Node

CMK Detailer Prepare -Pipe-

Where the detailer gets its own model, prompt and SAM

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK Detailer Prepare -Pipe-
  • MODEL
  • PROCESS
  • IMAGE
  • LOG
  • DETAILER
  • LOG
  • diagnostic
◄sam_model_name▾►
◄sam_device_modeCPU►
◄detailer_global_enablefalse►
◄use_prompt_lora_from_samplertrue►
◄use_lora_from_1st_passfalse►
◄use_1st_pass_samplingtrue►
◄lora_nameNone►
◄strength_model1.00►
◄strength_clip1.00►
◄prompt_pos►
◄prompt_neg►
◄steps30►
◄cfg7.0►
◄samplereuler►
◄schedulersimple►
◄stop_at_clip_layer-2►
◄pag_scale2.50►
◄samplingv_prediction►
◄zsnrtrue►
◄freeu_enabledtrue►
◄freeu_b11.30►
◄freeu_b21.40►
◄freeu_s10.90►
◄freeu_s20.20►

Every detailing workflow has the same hidden decision in it: does the second pass reuse the main sampler's model, LoRA and prompt, or does it get its own? CMK Detailer Prepare -Pipe- is that decision, made explicit, once, at the head of the module. It builds the frozen context that all of the detailer branches downstream share.

What it produces

One output: DETAILER, a CMK_DETAILER_PIPE. Everything a detailer pass needs to run is inside it - the model, the LoRA and prompt it will use, its sampling settings, and the SAM model used to refine detection masks. Plus LOG and a diagnostic, which is CMK's standard structured report payload (title, preview stages, summary, warnings, metrics) that you can chain into a log concat or a visualizer.

The inputs are MODEL (a CMK_MODEL_PIPE), PROCESS (a CMK_RESULT_PROCESS) and IMAGE. The documentation inside the node is precise about the contract, and it's worth repeating because it explains a lot of behaviour: MODEL is read-only - the detailer never mutates your main model pipe. IMAGE is the authoritative image, the one being detailed. PROCESS is read for shared context only: the prompt and LoRA offers coming down from the sampler, and the seed.

The settings that matter

  • sam_model_name - from ComfyUI/models/sams. If nothing is installed the single entry reads No SAM model installed, which is a clear enough error message for once.
  • sam_device_mode - AUTO, Prefer GPU or CPU, defaulting to CPU. SAM mask refinement on CPU is slow but doesn't fight your diffusion model for VRAM, and if your GPU is already at the edge, that's the right default.
  • detailer_global_enable - the module-wide off switch. Off means the branches don't run and the boundary nodes pass straight through.
  • use_prompt_lora_from_sampler (default on) - inherit the prompt and LoRA choices from the main sampler. This is the "just make the face better with the same recipe" mode.
  • use_lora_from_1st_pass (default off), use_1st_pass_sampling (default on) - the finer-grained versions of the same question, and the ones you flip when you want the detailer to use its own lora_name and strength_model/strength_clip instead.
  • prompt_pos / prompt_neg - the detailer's own prompts, used when it isn't inheriting.
  • steps (30), cfg (7), sampler (euler), scheduler (simple), sampling (v_prediction), zsnr (on), plus stop_at_clip_layer and pag_scale - the second pass's sampling setup, mostly advanced in the UI.

One default deserves a flag: FreeU is on by default, with freeu_b1 1.3, freeu_b2 1.4, freeu_s1 0.9, freeu_s2 0.2. Those are the familiar SDXL FreeU settings. FreeU changes what the detailer pass produces, so if you're chasing a "why does my detailer look slightly different from my other detailer" question, that's a candidate before you touch denoise.

How the second pass actually runs

Because it's the same engine across the module, it's worth knowing the whole loop: for each detected region, the detailer crops it, resizes the crop up to the guide size (capped by a max size), VAE-encodes it, runs the sampler on that crop with your denoise and a noise mask so only the mask region changes, decodes it, resizes it back to the original crop size, and then a final paste composites all of the regions in one pass. The per-region seed is your seed plus the segment index, so results are reproducible without a pile of per-face seeds. That's the mechanism behind "just zoom in and re-diffuse the region," which is all any detailer is doing.

Install

Manager: search CMK Flow → install the CMKFlow entry → restart. Manually, from the folder with main.py:

git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py

CMK dependency check: OK is the goal. Worth knowing before you install: the detailer is CMK's own - its own detector wrapper, SEGS container and SAM loader - so you do not need the Impact Pack, unlike almost every other ComfyUI detailer. The Python side is heavy regardless: ultralytics, onnxruntime, insightface, segment-anything, opencv-python, nudenet==3.4.2, straight into a shared environment with no isolation. The usual conflict warnings apply.

Models aren't in the package. Detectors go under models/ultralytics/bbox or segm, SAM under models/sams, and the resource check knows the filenames the shipped workflows expect:

python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/shared/models"

Turn on Vue Nodes / Nodes 2.0 - CMK hides and shows widgets based on mode and needs it.

Issues worth knowing

If the detailer runs but nothing improves, check the three inheritance toggles before anything else. A detailer with use_prompt_lora_from_sampler on and a main prompt that says nothing about faces will faithfully re-render the crop with the same generic guidance.

If the module seems dead, it's probably detailer_global_enable - it defaults to False, and the boundary node upstream will report a disabled passthrough rather than an error, which is easy to miss.

And if the SAM dropdown is empty, that's not a bug: mask refinement needs a SAM checkpoint in models/sams, and the dropdown tells you it isn't there.

CategoryCMK/Flow/PostProcess

Inputs (28)

NameTypeDefaultDescription
MODELCMK_MODEL_PIPE—
PROCESSCMK_RESULT_PROCESS—
IMAGEIMAGE—
sam_model_nameCOMBO1 options: No SAM model installed
sam_device_modeCOMBOCPU3 options: AUTO, Prefer GPU, CPU
detailer_global_enableBOOLEANfalse—
use_prompt_lora_from_samplerBOOLEANtrue—
use_lora_from_1st_passBOOLEANfalse—
use_1st_pass_samplingBOOLEANtrue—
lora_nameCOMBONone1 options: None
strength_modelFLOAT1.00-20–20—
strength_clipFLOAT1.00-20–20—
prompt_posSTRING—
prompt_negSTRING—
stepsINT301–10000—
cfgFLOAT7.00–100—
samplerCOMBOeuler44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBOsimple9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
stop_at_clip_layerINT-2-24–-1—
pag_scaleFLOAT2.500–20—
samplingCOMBOv_prediction3 options: eps, v_prediction, lcm
zsnrBOOLEANtrue—
freeu_enabledBOOLEANtrue—
freeu_b1FLOAT1.300–10—
freeu_b2FLOAT1.400–10—
freeu_s1FLOAT0.900–10—
freeu_s2FLOAT0.200–10—
LOGoptCMK_LOG_PIPE—

Outputs (3)

NameTypeDescription
DETAILERCMK_DETAILER_PIPE—
LOGCMK_LOG_PIPE—
diagnosticCMK_DIAGNOSTIC—