Nodes/ComfyUI_Lam/视频脸部融合
ComfyUI Node

视频脸部融合

Frame-by-frame face swap, straight onto a video

By yanlang0123·Created 2 years ago·Updated 10 days ago· 77
视频脸部融合
  • user_image
  • upscale_model
  • 视频文件名
templateVideoPath
filename_prefixcomfyUI
facedetection

VideoFaceFusion (视频脸部融合, "video face fusion") is the marquee node of the ComfyUI_Lam pack, and it does exactly what the name promises: take one photo of a face, swap it onto every frame of a video, and hand you back a finished MP4 with the original audio intact. It's the pixel-level face-swap lineage - the same family as ReActor and Roop - rather than the generative approach (IP-Adapter FaceID, InstantID) that nudges a diffusion model toward a face. Different tool, different result: this one literally replaces pixels, frame by frame.

How it works

The node loads the pack's face-fusion model from ComfyUI/models/image-face-fusion, opens the template video with OpenCV, and runs inference on every frame: detect the face in the template, blend your source face in, write the result. Frames go to disk via imageio, then ffmpeg extracts the source video's audio and muxes it back onto the swapped clip so you don't lose the original sound. The progress bars in the console (融合进度 / 写入进度) are a nice touch for a long-running job.

The inputs that matter:

  • templateVideoPath - STRING, forceInput. The video whose faces get replaced. Wire it from the pack's VideoPath node.
  • user_image - IMAGE. Your source face. First image in the batch wins.
  • filename_prefix - output name, saved to ComfyUI/output/video/.
  • facedetection - optional, defaults to retinaface_resnet50. Other options: retinaface_mobile0.25 (faster, slightly less accurate), YOLOv5l, YOLOv5n.
  • upscale_model - optional UPSCALE_MODEL. If you wire an upscaler (CodeFormer or similar), each swapped face runs through a full restore pipeline - detect, align, warp, restore, paste back - which sharpens the face at real cost to speed.

The single output is 视频文件名, the path to the saved MP4. It's an output node, so it's the end of its branch.

The model is the install blocker

Here's the part that stops most people: the face-fusion model is not on HuggingFace. The README links a Baidu Pan (pan.baidu.com) archive with an extraction code, to be unzipped into ComfyUI/models/image-face-fusion. Baidu Pan requires an account and is not exactly a joy outside mainland China, and without that model directory the node errors the moment it tries to load ImageFaceFusion. Budget for this when you decide whether the node is worth it.

The rest of the cost: the pack's requirements.txt includes insightface and opencv (insightface is famously picky to build on Windows outside the portable environment), and it needs ffmpeg on PATH for the audio step - the same silent-failure trap as the pack's other video nodes.

Speed and licensing, honestly

This is a slow node. A 30-second clip at 30fps is ~900 inference passes, and adding the face-restore pass with an upscaler multiplies that. It's a "start it, go make coffee" node. And the licensing deserves a mention: this whole face-swap family leans on InsightFace's pretrained models, which are MIT for code but non-commercial for the weights. Fine for personal fun, a legal headache for anything you sell. Read the license before you build a product on it.

Installing it

ComfyUI Manager (search "ComfyUI_Lam") or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

Restart, run the pack's install.bat for the heavy requirements, download the Baidu Pan model into ComfyUI/models/image-face-fusion, and make sure ffmpeg is on PATH.

Troubleshooting

  • "视频打开失败" - OpenCV couldn't open the template video; check the path and format.
  • "替换人脸照片不能为空" - the user_image batch was empty.
  • Silent missing output - that's ffmpeg not on PATH, same as every video node in this pack.
  • No model dir - the node throws at load; you'll know the moment you run it.
Categorylam

Inputs (5)

NameTypeDefaultDescription
templateVideoPathSTRING
user_imageIMAGE
filename_prefixSTRINGcomfyUI
facedetectionoptCOMBO4 options: retinaface_resnet50, retinaface_mobile0.25, YOLOv5l, YOLOv5n
upscale_modeloptUPSCALE_MODEL

Outputs (1)

NameTypeDescription
视频文件名STRING