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

CMK FaceProcess Prepare -Pipe-

The face module's own model, prompt and SAM — built once

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK FaceProcess Prepare -Pipe-
  • MODEL
  • PROCESS
  • IMAGE
  • LOG
  • FACE
  • LOG
  • diagnostic
◄sam_model_name▾►
◄sam_device_modeCPU►
◄face_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►

CMK FaceProcess Prepare -Pipe- is the head of the pack's face module: it takes your model pipe, your process context and an image, and produces a FACE pipe containing everything a face pass needs. It's the twin of the detailer prepare node, with a different downstream job.

Why there's a prepare step at all

Because a face pass shouldn't inherit whatever the main sampler happened to be doing. Face restoration and face re-detailer passes want their own prompt (you rarely want "wide shot, dramatic lighting" applied to a 300-pixel face crop), their own LoRA sometimes, and their own sampling settings. CMK's answer is to make that a frozen context object rather than a pile of wires you re-plumb every time.

The contract, as the node's own documentation states it: MODEL is read-only and never mutated, IMAGE is the authoritative image being processed, and PROCESS is read only for shared context - the prompt and LoRA offers from the sampler, and the seed.

Inputs

MODEL (CMK_MODEL_PIPE), PROCESS (CMK_RESULT_PROCESS) and IMAGE are the three required wires.

Then the context settings:

  • sam_model_name - from ComfyUI/models/sams. With nothing installed it shows the single entry No SAM model installed, which is at least honest.
  • sam_device_mode - AUTO, Prefer GPU, CPU. Default is CPU, which is the right call when your GPU is already near the edge during sampling; it's slower but it doesn't evict anything.
  • face_global_enable - the module-wide switch, default False.
  • use_prompt_lora_from_sampler (on), use_lora_from_1st_pass (off), use_1st_pass_sampling (on) - the inheritance triad. On means "reuse the main recipe"; flip them when the face pass needs its own.
  • lora_name (default None), strength_model, strength_clip - an optional module-local LoRA.
  • prompt_pos / prompt_neg - the face pass's own prompts; these get encoded into conditioning inside this node, which is why the pipe can carry a complete basic-pipe later.
  • steps (30), cfg (7), sampler (euler), scheduler (simple), stop_at_clip_layer (-2), pag_scale (2.5), sampling (v_prediction), zsnr (on) - the sampling setup, mostly advanced in the UI.
  • FreeU: freeu_enabled is on by default, with freeu_b1 1.3, freeu_b2 1.4, freeu_s1 0.9, freeu_s2 0.2. Flag that one - people spend a while wondering why their face pass doesn't look like a vanilla render when FreeU is quietly on.

Optional LOG lets you chain the module's reporting upstream. Outputs are FACE (CMK_FACE_PIPE), LOG and a diagnostic.

What happens downstream

The FACE pipe carries the prepared model, CLIP, VAE and encoded positive/negative conditioning - effectively a basic pipe plus the face-specific settings - which is exactly what the face module's detailer path needs, since the re-render step is a crop, resize, VAE encode, sample with a noise mask, decode and paste. It also carries the detection and selection state so the execute node doesn't have to re-derive it.

That's the reason the prepare exists as its own node rather than as widgets on the execute node: the expensive, once-per-run setup - model load, LoRA application, prompt encoding, SAM load - happens here, once, and every face branch downstream reads the same frozen result.

Install

Manager: search CMK Flow, install the CMKFlow entry, restart. Manually, from the folder containing 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

Wait for CMK dependency check: OK - after a manual clone nothing runs pip for you, and this node imports enough of the pack that a partial install shows up as an import error on startup rather than at run time. requirements.txt is a real commitment: ultralytics, onnxruntime, insightface, segment-anything, imageio-ffmpeg, opencv-python, nudenet==3.4.2, all into your shared environment.

Models aren't in the package: SAM under models/sams, face detectors under models/ultralytics/bbox (or segm), restore networks under models/facerestore_models. Audit what the bundled workflows expect with:

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

Enable Vue Nodes / Nodes 2.0 - CMK's dynamic widgets need it.

Issues worth knowing

Everything is optional from ComfyUI's validation standpoint and the frontend rebuilds the visible widget list per mode, so a hidden widget can't be reported as missing. That's good design, and it also means an unwired mode-specific input fails at run time with a clearer message rather than at queue time. If a face pass dies on a missing input, read the message - it names the parameter.

face_global_enable defaults to off. If the face module does nothing and reports nothing alarming, look there first; the boundary node upstream will have logged a disabled passthrough.

And if the SAM dropdown is empty, mask refinement isn't available yet. Detection still works - the detectors are YOLO - but the polygon masks won't be 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
face_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
FACECMK_FACE_PIPE—
LOGCMK_LOG_PIPE—
diagnosticCMK_DIAGNOSTIC—