CMK InstantID Face Rebuild · Pasteback
Put the rebuilt face exactly back
- TARGET IMAGE
- REBUILT ROI
- PASTEBACK MASK
- REBUILD CONTEXT
- IMAGE
- PASTEBACK MASK
- LOG BLOCK
- diagnostic
Compositing a refined crop back onto the original is the step everyone underestimates. Get it wrong and you get a visible rectangle, a ghosting seam, or worse: the rest of the image quietly resamples and you've lost detail in places you never touched. CMK InstantID Face Rebuild · Pasteback is the discrete, no-pipes version of the rejoin step, and it's unusually paranoid about exactly that failure.
What goes in
TARGET IMAGE- the original, unmodified frame.REBUILT ROI- the finished crop that came out of the detailer.PASTEBACK MASK- the full-size mask the prepare node produced.REBUILD CONTEXT- theCMK_FACE_REBUILDbundle (ROI coordinates, working size, feather) that ties the crop back to where it came from.PASTEBACK NECK- off by default. The tooltip: "Include the generated neck ellipse in final pasteback without resampling the rebuilt ROI." In other words, the neck region gets composited at whatever resolution it exists in rather than being scaled up and re-fitted.
Out: IMAGE, PASTEBACK MASK, LOG BLOCK, diagnostic.
The mechanism worth understanding
Two things are happening that you don't see.
First, the mask is rebuilt from the context rather than trusted from upstream. The node reconstructs the geometry from the stored ROI, working size and feather, then regenerates the pasteback mask with or without the neck - so the mask you feed in and the mask it uses can differ. The output PASTEBACK MASK is the effective one, and it's what you should wire onward if you're doing anything else mask-based.
Second, the composite is verified. The node takes the ROI slice of the target, applies the mask, and checks that everything outside the mask came back bit-identical. The log reports Outside Unchanged : PASS or FAIL, and the diagnostic payload carries an Integrity PASS / Integrity FAIL mode plus a metric for it. If the pack's mask geometry has drifted, you find out here instead of noticing a faint ghost three generations later.
The naming matters here: this is the "pasteback inset" half of the pack's mask separation. The inpaint mask from Prepare is broader than the pasteback mask, so the model has room to blend context, but only the inset region - head, plus neck if you asked for it - is allowed to overwrite the original. That's the trick that keeps seams from appearing where the inpainting had soft edges.
Inputs it won't accept
The context has to be a real CMK_FACE_REBUILD dict or you get "InstantID Face Rebuild Pasteback requires a valid rebuild context". The batch dimension has to be exactly 1 on the target, the rebuilt ROI and the mask - this prototype path is single-image by design. And a mask that doesn't match the target's dimensions is rejected rather than resized for you, which is the right call: silently resizing a pasteback mask is how you get a face pasted in the wrong place.
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
Or ComfyUI Manager → CMK Flow (registry cmk-flow) → restart. The manual clone does not run pip; the installer script is mandatory, and it's what pulls insightface, onnxruntime, ultralytics and the rest of the pack's fairly heavy dependency set.
Should you use this or the pipe version?
If you're building inside a CMK flow, use CMK Flow · InstantID Face Rebuild · Pasteback instead - it carries MODEL, PROCESS and LOG through, so the pipe never gets broken, and it has a proper bypass path that returns the original pixels untouched when FaceRebuild is disabled.
Use this one when you're doing the rebuild as discrete nodes: your own crop, your own detailer, then paste it back with a guaranteed-clean boundary. It's the piece you'd pull out of the pack if you wanted the integrity check without adopting the whole pipeline.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| TARGET IMAGE | IMAGE | — | |
| REBUILT ROI | IMAGE | — | |
| PASTEBACK MASK | MASK | — | |
| REBUILD CONTEXT | CMK_FACE_REBUILD | — | |
| PASTEBACK NECK | BOOLEAN | false | Include the generated neck ellipse in final pasteback without resampling the rebuilt ROI. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| PASTEBACK MASK | MASK | — |
| LOG BLOCK | CMK_LOG_BLOCK | — |
| diagnostic | CMK_DIAGNOSTIC | — |