Nodes/comfyui_facetools/Warp Faces Back
ComfyUI Node

Warp Faces Back

The paste-back that leaves everything but the face alone

By dchatel·Created 2 years ago·Updated 11 months ago· 183
Warp Faces Back
  • images
  • face
  • crop
  • mask
  • warp
  • IMAGE

This is the payoff node. DetectFaces found the faces, CropFaces pulled them out and made masks, you did your inpaint or LoRA pass on the crops - and now WarpFacesBack glues the results back into the original image. The whole point of the facetools pipeline is in that name: it warps faces back, using the stored warp matrix, and it never regenerates the rest of the frame.

That's the property people actually reach for this pack over FaceDetailer for. A standard detailer resamples the whole image through its region and can drift the surrounding pixels, shift colors, or fight with a LoRA you want to keep. Here, the background is the original image, bit for bit. If your goal is "fix this face, change literally nothing else," that's a promise FaceDetailer makes awkwardly and this node makes structurally.

How it works

You feed it five inputs, all in the same order they came out of the pipeline:

  • images - the original, unmodified batch from before DetectFaces
  • face - the FACE list from DetectFaces
  • crop - the detailed crops from CropFaces
  • mask - the masks from CropFaces
  • warp - the warps from CropFaces

Internally it groups each crop by which source image it came from (the FACE objects carry that index), then inverts the affine warp and splats each crop back into place with Lanczos interpolation. Where multiple faces overlap, the masks decide the blend - overlapping regions get a weighted average instead of a hard seam, so a group shot with two faces pasted back doesn't show a line down the middle.

One thing to know: it expects images to be the original tensor, in the same order you fed DetectFaces. Change the order, add an upscale step in between, and the paste-back silently lands in the wrong place. Keep the image side of the graph untouched from DetectFaces through to here.

The one output

A single IMAGE. Wire it to a preview or a Save Image node and that's your finished composite. If a face crop wasn't detected in a given image, that image passes through unchanged - which is the graceful behavior you want when you batch a folder where not every frame has a face.

Gotchas

  • Order matters. Original images, faces, crops, masks, warps all have to be the same count and order. Mixing up crop and mask order is the #1 cause of "the face came back looking blurry and wrong."
  • No blur on the mask edge. The node does a straight masked blend; if you can see the seam, feather the mask upstream or lower your refine pass's denoise so the crop's edges match the original better.
  • The README's patch notes mention that this node changed after MergeWarps was written - the author notes MergeWarps "probably doesn't work anymore." So build your multi-face workflows off WarpFacesBack's current behavior, not the merge node.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/dchatel/comfyui_facetools

or ComfyUI Manager → search facetools → install → restart. This node itself is pure torch/numpy/OpenCV, so it has no extra model downloads of its own - the dependencies come from DetectFaces and CropFaces upstream. If you got this far in the pipeline, you already have everything it needs.

Categoryfacetools

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
faceFACE
cropIMAGE
maskMASK
warpWARP

Outputs (1)

NameTypeDescription
IMAGEIMAGE