Nodes/ComfyUI-FaceChain/FC FaceSegAndReplace
ComfyUI Node

FC FaceSegAndReplace

Face swap plus a clean paste-back mask, in one pass — FC FaceSegAndReplace

By THtianhao·Created 3 years ago·Updated about a year ago· 147
FC FaceSegAndReplace
  • source_image
  • replace_image
  • fusion
  • fusion seg replace

FC FaceSegAndReplace is the "do the whole job" face swap: it fuses a new face onto your image and composites the result back over the original in one node. Where plain FC FaceFusion hands you a raw fused image and makes you handle the blending, this node segments the face, uses the segmentation as a paste mask, and returns both a straight fusion and a cleanly replaced result.

The README frames it as the multi-person-friendly variant of FaceFusion - same fusion engine, plus the segmentation step so the swap stays inside the face boundary instead of bleeding into hair, neck, and shoulders. That's a genuinely useful difference: the "replace" output is much closer to what you'd actually save to disk, with no extra mask-wrangling step.

Inputs and outputs

Two required inputs, both IMAGE:

  • source_image - the template/background photo (whose pose and body you keep)
  • replace_image - the identity to fuse in

Two IMAGE outputs:

  • fusion - the raw fused face image, no compositing (the same kind of result FC FaceFusion gives)
  • fusion seg replace - the fusion composited back onto the source using the segmented face mask

How it works

It runs the ModelScope UNet fusion (damo/cv_unet_face_fusion_torch), then runs the human-parsing segmentation model (damo/cv_resnet101_image-multiple-human-parsing) on the source image to get a face mask, and blends: fused pixels inside the face, original pixels outside. Because the mask comes from a segmentation model rather than a plain bounding box, the seam follows the actual face contour - which is exactly what keeps a swapped face from looking pasted on.

That's also the failure mode to watch: if the segmentation model misses part of the face (strong shadows, glasses, a hand over the chin), that region stays original while the rest swaps, and you get a Frankenstein result. When that happens, don't fight this node - fall back to FC FaceFusion plus FC FaceSegment + FC ReplaceByMask, where you can see and fix the mask yourself.

Install and first-run notes

ComfyUI Manager (search "ComfyUI-FaceChain") or git clone https://github.com/THtianhao/ComfyUI-FaceChain into custom_nodes/, then restart. Two downloads happen on first use - the fusion model and the segmentation model, both from ModelScope - so the first run is slow and needs access to modelscope.cn. The pack's startup dependency install (onnxruntime-gpu, mmdet, mmcv, modelscope, insightface, transformers…) also applies to the whole pack, so budget a slow first launch regardless.

If you're doing a single-person swap and want the least-fuss path to a finished image, this is the node to reach for in this pack. Just keep the segmentation caveat in mind - the automated mask is the whole trick, and it's only as good as the model's read on the face.

Categoryfacechain/model

Inputs (2)

NameTypeDefaultDescription
source_imageIMAGE
replace_imageIMAGE

Outputs (2)

NameTypeDescription
fusionIMAGE
fusion seg replaceIMAGE