Nodes/CMK Flow/CMK FaceSwap Image -Pipe-
ComfyUI Node

CMK FaceSwap Image -Pipe-

The FaceSwap That Knows Which Model Made the Image

By CMKFlow·Created 3 months ago·Updated 2 days ago· 6
CMK FaceSwap Image -Pipe-
  • IMAGE_TARGET
  • IMAGE_SOURCE
  • PROCESS
  • opt_log
  • VISUAL
  • opt_diagnostic
  • IMAGE PROCEED
  • SEGS PROCESSED
  • LOG
  • VISUAL
  • diagnostic
◄GLOBAL ENABLEtrue►
◄ENABLEtrue►
◄SWAP MODELinswapper_128.onnx►
◄DETECT MODEL▾►
◄TARGET FACELargest►
◄SOURCE FACELargest►
◄PATCH ENHANCERtrue►
◄PATCH ENHANCER MODELOff►
◄PATCH ENHANCER STRENGTH1.00►
◄BLEND1.00►
◄bbox_dilation0►
◄crop_factor1.5►
◄drop_size10►
◄feather0►
◄IDENTITY STRENGTH1.00►
◄QUALITY PROFILEAutomatic►
◄POST RESTOREfalse►
◄POST RESTORE MODELnone►
◄RESTORE VISIBILITY1.00►
◄_cmk_content_guard_enabledtrue►

The -Pipe- suffix in CMK Flow means one thing: this node belongs to the guided pipeline and speaks its private types. Where CMK FaceSwap Image is a comfort node you can bolt anywhere, CMK FaceSwap Image -Pipe- is the version that arrives with the flow's process state attached - and that turns out to buy it a genuinely useful trick.

The trick: quality profiles

The node takes a PROCESS pipe, reads the source model family off it, and if QUALITY PROFILE is left on Automatic it picks its swap settings for you. SDXL runs get a hard swap - blend 1.0, crop factor 1.5, feather 22, identity strength 1.0. Z-Image Turbo runs get a softer one - blend 0.70, crop factor 1.3, feather 30, identity strength 0.85.

That's not arbitrary. Flow-matching models like Z-Image produce a different texture than SDXL's DDPM-style output, so the same hard paste that looks clean on SDXL reads as a plastic hole in a ZIT render. Picking the profile by hand (SDXL / ZIT) overrides the auto-detect; Custom stops the node from touching your numbers at all. If you want Custom, note that the profile assignment overwrites BLEND, crop_factor, feather and IDENTITY STRENGTH for you - so set the profile first, then dial.

What else is different

Two enables, not one. GLOBAL ENABLE and ENABLE are ANDed. Global is the pipeline's master switch; local is "this module". With either off, the node is a true pass-through: it reports SOURCE LOAD: SKIPPED and FACE DETECTION: SKIPPED in its log and returns the target untouched. It doesn't even load the source image - IMAGE_SOURCE is lazy and only requested when the module is actually enabled.

An enhancer split into three controls. PATCH ENHANCER turns restoration on, PATCH ENHANCER MODEL is the model (Off or GPEN), and PATCH ENHANCER STRENGTH blends how much of the restored patch you keep. That last one is the control the standalone node doesn't give you, and it's the one that stops GPEN from over-smoothing.

POST RESTORE is a second, later restore pass over the final result - on by request, off by default, with RESTORE VISIBILITY controlling how much of it lands.

As with the rest of the pack's public swap paths, the ContentGuard runs first and fails hard. No switch.

Inputs and outputs

IMAGE_TARGET is required; IMAGE_SOURCE, PROCESS, opt_log, VISUAL and opt_diagnostic are optional. If ENABLE is on and no source is connected, the node raises rather than silently producing a target pass-through - that's deliberate, it's the failure people otherwise ship without noticing. TARGET FACE, SOURCE FACE, SWAP MODEL, DETECT MODEL, BLEND, bbox_dilation, crop_factor, drop_size and feather are the same anatomy as the standalone node.

Outputs: IMAGE PROCEED is the swapped image; SEGS PROCESSED carries the paste-back regions so later CMK modules know where work happened; LOG and VISUAL are pipeline transports - the VISUAL output registers the stage in the flow's visualizer as sequence 40, which is how the before/after comparison shows up; diagnostic is the per-run payload.

Note there's no selected-face input here. The pipe version detects internally by rule; if you need to hand-pick a face, that's the standalone CMK FaceSwap Image plus CMK Face Select.

Install

Manager: search CMK Flow, install, restart. Manual, from your ComfyUI root:

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

You need the weights (inswapper_128.onnx, buffalo_l, optionally a GPEN restore model) and - the requirement people trip on - ComfyUI's Nodes 2.0 / Vue setting, without which CMK's dynamic nodes render on the old canvas and lose their advanced toggles.

Where people get burned

If you paste this node into a graph that doesn't come from a CMK flow, PROCESS is the trap: the node needs process state to resolve the family, and Custom is the profile that means "ignore all of that". Reach for the standalone node if you don't have the pipe.

Second, the two enables. People flip ENABLE off, see the target come out unchanged, and assume the node is broken. It isn't - the log says passthrough in plain text.

Third, and this is the one that costs time: swap speed. The pack's swap inference defaults to ONNX Runtime's CPU provider, so a 1-megapixel image is seconds, not milliseconds, and resolution scales that. Budget for it and run this after you've settled composition, not in the loop while you're iterating on a prompt.

CategoryCMK/Flow/Face

Inputs (26)

NameTypeDefaultDescription
IMAGE_TARGETIMAGE—
IMAGE_SOURCEoptIMAGE—
GLOBAL ENABLEoptBOOLEANtrue—
ENABLEoptBOOLEANtrue—
SWAP MODELoptCOMBOinswapper_128.onnx1 options: inswapper_128.onnx
DETECT MODELoptCOMBO1 options: buffalo_l
TARGET FACEoptCOMBOLargest6 options: Largest, Leftmost, Rightmost, Topmost, Bottommost, Center
SOURCE FACEoptCOMBOLargest6 options: Largest, Leftmost, Rightmost, Topmost, Bottommost, Center
PATCH ENHANCERoptBOOLEANtrue—
PATCH ENHANCER MODELoptCOMBOOff2 options: Off, GPEN
PATCH ENHANCER STRENGTHoptFLOAT1.000–1—
BLENDoptFLOAT1.000–1—
bbox_dilationoptINT0-512–512—
crop_factoroptFLOAT1.51–3—
drop_sizeoptINT101–8192—
featheroptINT00–100—
IDENTITY STRENGTHoptFLOAT1.000.5–1.5—
QUALITY PROFILEoptCOMBOAutomatic4 options: Automatic, SDXL, ZIT, Custom
POST RESTOREoptBOOLEANfalse—
POST RESTORE MODELoptCOMBOnone1 options: none
RESTORE VISIBILITYoptFLOAT1.000–1—
PROCESSoptCMK_PIPE—
opt_logoptCMK_LOG_PIPE—
VISUALoptCMK_VISUAL_PIPE—
opt_diagnosticoptCMK_DIAGNOSTIC—
_cmk_content_guard_enabledoptBOOLEANtrue—

Outputs (5)

NameTypeDescription
IMAGE PROCEEDIMAGE—
SEGS PROCESSEDSEGS—
LOGCMK_LOG_PIPE—
VISUALCMK_VISUAL_PIPE—
diagnosticCMK_DIAGNOSTIC—