Nodes/ComfyUI-UtilsCollection/MediaPipe Face Composite
ComfyUI Node

MediaPipe Face Composite

Swap a face without training a thing — MediaPipe + BiRefNet, no InsightFace drama

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
MediaPipe Face Composite
  • source
  • target
  • face_detection_model
  • background_removal_model
  • options
  • image
  • Face Crop

UC_MediaPipeFaceComposite takes the largest face in one image and composites it onto the largest face in another - a straight, no-training face swap. The notable part isn't the goal, it's the stack underneath: this uses MediaPipe for detection, not InsightFace. That matters more than you'd think, because InsightFace's pretrained models carry a non-commercial license that quietly infects every project built on them. MediaPipe is Apache 2.0. If your face-swap tooling has to be sellable, this is the route, and it's the same swap Kijai made for LivePortrait back in 2024 for exactly that reason.

It's part of silveroxides/ComfyUI-UtilsCollection. Be clear about what it is and isn't: this is detection-plus-geometry, not an identity-embedding tool like InstantID or IP-Adapter FaceID. You're physically warping the source face onto the target's face - same pose, same lighting. Great for consistent-characters-for-free, head swaps, and "make this character look like that person" jobs; it will not transfer identity into a brand-new scene the way an embedding-based tool does.

How it works

Under the hood it's a small pipeline: MediaPipe detects faces in both images at full range, takes the largest in each, and builds a landmark ring around the face (the face_oval connection set). It computes a similarity transform - scale, rotation, translation - mapping the source ring onto the target ring, then warps the source crop over the target face. The foreground is cut out with a BiRefNet background-removal model so hair and shoulders come along, and the whole thing is feathered so the seam hides. Warp strength and decay are controlled by the options node (UC_MediaPipeFaceCompositeOptions).

Inputs that matter

  • source / target - the two images. Exactly one of each; the node errors out if you feed it a batch, so swap one image at a time (or loop them).
  • options - plug in the options node to tune warp, feathering, and detection threshold. Leave it disconnected for defaults.
  • face_detection_model - optional; a Core FACE_DETECTION_MODEL. Disconnected, it loads mediapipe_face_fp32.safetensors.
  • background_removal_model - optional; a Core background-removal model. Disconnected, it uses the internal BiRefNet model.

Outputs

  • image - the composited result.
  • Face Crop - the swapped face crop, handy if you want the face alone for a detailer pass.

Installing it

Via the pack:

  • ComfyUI Manager: search "ComfyUI-UtilsCollection".
  • Or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Restart ComfyUI. This node does pull models, and they're not bundled with the pack - it needs a MediaPipe face model and a BiRefNet background-removal model in your Core model folders. The first run raises an error telling you exactly what's missing and where to put it:

  • mediapipe_face_fp32.safetensors from Comfy-Org/mediapipeComfyUI/models/detection/
  • the BiRefNet file from Comfy-Org/BiRefNetComfyUI/models/background_removal/

The pack's pip requirements are just opencv-python and typing-extensions; the MediaPipe model runs through Comfy Core's own face-landmarker, so you don't install the standalone mediapipe package.

Gotchas

The first-run model download is the most common "it's broken" report - read the error message, it literally prints the download URL and target folder. Detection threshold (score_thresh in the options node) is your friend when it picks the wrong face or misses one. And remember the single-image limit: batch inputs throw. The biggest practical caveat is the usual one for geometric swaps - if the source and target are at wildly different angles or lighting, the warp can only do so much, and the swap starts looking like a mask. Turn target_warp_strength down to keep more of the source's natural shape when that happens. It's the one knob that turns "uncanny" into "fine."

Categoryutils/image

Inputs (5)

NameTypeDefaultDescription
sourceIMAGE
targetIMAGE
face_detection_modeloptFACE_DETECTION_MODELOptional Core MediaPipe face model. Uses mediapipe_face_fp32.safetensors when disconnected.
background_removal_modeloptBACKGROUND_REMOVALOptional Core background-removal model. Uses the internal BiRefNet model when disconnected.
optionsoptUC_FACE_COMPOSITE_OPTIONS

Outputs (2)

NameTypeDescription
imageIMAGE
Face CropIMAGE