Nodes/CMK Flow/CMK FaceSwap Image Input
ComfyUI Node

CMK FaceSwap Image Input

One node, two images, and they are deliberately treated differently

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK FaceSwap Image Input
    • PROCESS
    • IMAGE TARGET
    • IMAGE SOURCE
    • LOG
    • diagnostic
    ◄RESOLUTIONSDXL 1152x832►
    ◄SWAP DIMENSIONSfalse►
    ◄RESIZE METHODlanczos►
    ◄CROPfalse►
    ◄CROP POSITIONcenter►
    ◄IMAGE PAIR{"target":"","source":""}►

    A face swap needs two pictures: the target (whose face gets replaced) and the source (the face doing the replacing). Every workflow gets this wrong once, because the obvious loader is one Load Image node and you end up wiring a resize into both paths, or a crop into the wrong one, and the source face comes back subtly distorted for reasons that take an hour to find. CMK FaceSwap Image Input exists to make that mistake impossible: it loads both images in a single two-column picker and applies resizing to exactly one of them.

    Its category is CMK/Toolbox/I-O, i.e. the open side of the pack - you can drop it into a non-CMK graph, and its PROCESS output is deliberately family-neutral so it can also feed standalone CMK post-processing like FaceRebuild.

    How it works

    The contract, stated in the docstring and worth internalising: the target follows the complete CMK Load Image contract, including optional aspect-ratio crop; the source is loaded without crop or resize.

    That asymmetry is the whole design. Your target is going into a generative pipeline and needs to be a sane, model-friendly size with the right aspect ratio. Your source is being used as an identity reference or swapped directly as pixels - any resampling there is damage, so CMK does not touch it. IMAGE TARGET and IMAGE SOURCE are independent authoritative pixel transports; the PROCESS output carries metadata only.

    The IMAGE PAIR widget is a single STRING holding JSON - {"target":"","source":""} - which the pack's frontend renders as the two-column selection surface (same pattern the video FaceSwap loader uses for video + source). If you are building a graph programmatically, that's the field you write. Cropping implements the same aspect-ratio-preserving behaviour as the rest of CMK: CROP POSITION picks which part of the frame survives the resize, so you get letterbox-style preservation instead of a squashed face.

    Inputs and outputs

    The ones you'll actually touch:

    • IMAGE PAIR - the target/source picker. This is the node's real UI.
    • RESOLUTION - 20 presets, default SDXL 1152x832. The target lands on this; the source doesn't care.
    • CROP POSITION - center, top, bottom, left, right. Only relevant when CROP is on. Default CROP is off here, unlike the general-purpose load-and-resize node where it defaults on - a deliberate difference, since cropping a faceswap target can cut the head.

    The rest: SWAP DIMENSIONS (flip the target to portrait), RESIZE METHOD (lanczos, bicubic, bilinear, nearest).

    Outputs: PROCESS (CMK_RESULT_PROCESS - the family-neutral metadata context), IMAGE TARGET, IMAGE SOURCE, LOG, diagnostic. Wire target and source into the FaceSwap module; keep PROCESS for anything downstream that wants the run context, and hang a CMK Summary off diagnostic if you want the readout.

    Install

    Manager → search CMK Flow → install the cmkflow entry → restart. Manual:

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

    This one is worth the resource check even if you only want the loader, because the FaceSwap path it feeds is the pack's heaviest dependency chain:

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

    Under the hood you're pulling insightface (detection and identity embeddings), onnxruntime, opencv-python and the inswapper swap model, plus nudenet==3.4.2 for the ContentGuard. Be warned: InsightFace is the single most complained-about install in this corner of the ecosystem - it's the one dependency people give up on - and its pretrained ONNX models carry non-commercial terms, which matters if you're selling output. That's a licensing reality of the whole face-swap category, not a CMK choice.

    Common issues

    • The picker won't show your image. Both images come from the standard ComfyUI input directory; use the node's own upload slot rather than copying files in behind its back, so its listing refreshes.
    • The source face looks soft or wrong. Check you didn't route it through a resize somewhere downstream. The node deliberately doesn't resize it - don't undo that.
    • The swap aborts with a guard error. That's the ContentGuard, not a bug. CMK's public FaceSwap paths run a mandatory local check (NudeNet for explicit content, InsightFace age estimation) on both images before swapping, and refuse on explicit content, an estimated age under 18, or a source face under a conservative 25 threshold. There is no bypass switch in the public interface, and a disabled FaceSwap node skips the guard entirely rather than passing through it.
    • Nothing is missing but the node won't register. Confirm the pack loaded at all - a failed insightface wheel build leaves the whole extension unregistered, which looks like "the node doesn't exist."
    CategoryCMK/Flow/Input

    Inputs (6)

    NameTypeDefaultDescription
    RESOLUTIONCOMBOSDXL 1152x83220 options: 1024x1024, 1152x832, 832x1152, 1216x832, 832x1216, 1344x768, +14
    SWAP DIMENSIONSBOOLEANfalse—
    RESIZE METHODCOMBOlanczos4 options: lanczos, bicubic, bilinear, nearest
    CROPBOOLEANfalse—
    CROP POSITIONCOMBOcenter5 options: center, top, bottom, left, right
    IMAGE PAIRSTRING{"target":"","source":""}—

    Outputs (5)

    NameTypeDescription
    PROCESSCMK_RESULT_PROCESS—
    IMAGE TARGETIMAGE—
    IMAGE SOURCEIMAGE—
    LOGCMK_LOG_PIPE—
    diagnosticCMK_DIAGNOSTIC—