Nodes/CMK Flow/CMK Flow · InstantID Face Rebuild · Prepare
ComfyUI Node

CMK Flow · InstantID Face Rebuild · Prepare

The crop step that keeps your pipe alive

By CMKFlow·Created 3 months ago·Updated 2 days ago· 6
CMK Flow · InstantID Face Rebuild · Prepare
  • PROCESS
  • IMAGE
  • LOG
  • PROCESS
  • IMAGE
  • LOG
  • TARGET ORIGINAL
  • PASTEBACK MASK
  • REBUILD CONTEXT
  • diagnostic
◄FACEREBUILD ENABLEtrue►
◄ENABLEtrue►
◄TARGET FACELargest►
◄HEAD AREA0.75►
◄NECK AREA0.40►
◄MASK FEATHER32►
◄WORKING RESOLUTION1024►
◄DETECT MODELbuffalo_l►
◄DETECT SIZE640►

If you're building inside CMK Flow, this is the prepare node you want - it does the same detection and cropping as the discrete version, but it takes PROCESS and LOG in and gives them back, so the module stays connected to the rest of the pipeline. It also does something the discrete version can't: it rewrites the process context to describe the crop it just made.

That's the interesting bit. After this node runs, the process pipe's resolution, target size, generation mode (img2img_detailer) and face_rebuild_face_bbox all refer to the face ROI rather than your full image. Downstream sampling nodes therefore sample the crop at 1024 (or whatever WORKING RESOLUTION says) without you rewiring anything.

One consequence is visible in the source comments: this adapter has no source-face picker at all. The canonical InstantID module owns that, so the prepare step only needs target geometry - it feeds its own IMAGE in as the "source" internally and hands the real SOURCE FACE straight out for the detailer to use.

Two enable flags, on purpose

  • FACEREBUILD ENABLE - the global switch for the module.
  • ENABLE - the flow-level switch for this instance.

Both must be on for anything to happen. Miss one and you get a bypass path that returns your image unchanged, a zero mask, and a context marked bypassed: True, with the reason spelled out in the log block (Global Enable: OFF, Flow Enable: ON, Status: BYPASSED). Two switches looks fussy until you're running parallel rebuild instances and want to kill one without touching the others - or disabling the whole technique at the top of a workflow while keeping the graph readable.

Wiring

In: PROCESS, IMAGE, LOG, plus TARGET FACE, HEAD AREA (0.75), NECK AREA (0.4), MASK FEATHER (32), WORKING RESOLUTION (768/1024/1280), DETECT MODEL, DETECT SIZE (640).

Out: PROCESS (updated for the crop), IMAGE (the ROI), LOG, TARGET ORIGINAL, PASTEBACK MASK, REBUILD CONTEXT, diagnostic.

TARGET ORIGINAL is the untouched input image, held on the output side specifically so the pasteback node doesn't need a second branch of the graph dangling back up to the source. Small thing, saves a lot of noodle.

It will not run without the right process

The node checks process["result_contract"] == "family_neutral" and raises "InstantID Face Rebuild requires the PostProcess Boundary" if it doesn't match. That's the pack's family-neutrality contract: SDXL, Z-Image Turbo and HYBRID generation paths stay separate while generating, and the PostProcess Boundary is what hands over a process object with no family assumptions left in it. You can't feed it a mid-generation process and expect it to work.

Install

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

Manager route: search CMK Flow (registry cmk-flow, publisher CMKFlow), install, restart. Note that a manual git clone never runs pip - the installer script is part of the install, and again after every git pull --ff-only. There's a resource checker too, which is worth running before you debug anything face-related:

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

Turn on Vue Nodes / Nodes 2.0 - CMK prints a startup warning when it's off, and these nodes' advanced folding and dynamic sizing assume it.

The honest caveat about pipes

Bundling state onto one wire is the pattern this whole pack is built on, and it has a known failure mode: stale context. Because the process object carries resolution, bounding box and enable flags, it's easy to reason about the crop while forgetting that the bundle also decides the sampling resolution for everything downstream. When a rebuild looks blurry or strangely scaled, read the log block and the diagnostic before touching sampler settings - the numbers are right there in the context, and they're usually the ones you didn't intend.

CategoryCMK/Developer/Legacy Prepare

Inputs (12)

NameTypeDefaultDescription
PROCESSCMK_RESULT_PROCESS—
IMAGEIMAGE—
LOGCMK_LOG_PIPE—
FACEREBUILD ENABLEBOOLEANtrue—
ENABLEBOOLEANtrue—
TARGET FACECOMBOLargest6 options: Largest, Leftmost, Rightmost, Topmost, Bottommost, Center
HEAD AREAFLOAT0.750–2—
NECK AREAFLOAT0.400–2—
MASK FEATHERINT320–64—
WORKING RESOLUTIONCOMBO10243 options: 768, 1024, 1280
DETECT MODELCOMBObuffalo_l1 options: buffalo_l
DETECT SIZEINT640128–1280—

Outputs (7)

NameTypeDescription
PROCESSCMK_RESULT_PROCESS—
IMAGEIMAGE—
LOGCMK_LOG_PIPE—
TARGET ORIGINALIMAGE—
PASTEBACK MASKMASK—
REBUILD CONTEXTCMK_FACE_REBUILD—
diagnosticCMK_DIAGNOSTIC—