Unlock the Secrets of Ancient Beauty: A High-Precision Face Swapping Workflow

CN
ComfyUI.org
2025-05-09 09:40:07

1. Workflow Overview

maglqjtbd91h5ixj0qs9907598c91b237774e60c5c2979594160278dc04220dd34ad1a7cc0b226e1945.png

This workflow specializes in high-precision face swapping, optimized for classical Chinese portraits (e.g., replacing modern faces with Yang Guifei's style). Key steps:

  1. Face Detection & Cropping: Auto-detects faces in source/target images.

  2. Model Swapping: Uses inswapper_128.onnx for feature transfer.

  3. Quality Enhancement: Applies GFPGANv1.4 for facial detail restoration.

  4. Color Adaptation: Leverages color101VAE for skin tone consistency.

Highlights: Multi-angle support, preserves original lighting, adapts to ancient makeup.


2. Core Models

Model/Component

Function

Source

inswapper_128.onnx

Core face-swapping model (128px)

ReActor GitHub

GFPGANv1.4.pth

Face restoration

Manual download to ComfyUI/models/face_restoration

color101VAE_v1.pt

Color-matching VAE

Place in ComfyUI/models/vae

retinaface_mobile0.25

Lightweight face detector

Auto-downloaded


3. Key Nodes

Node Name

Function

Installation

ReActorFaceSwap

Executes face swap & enhancement

Install ComfyUI-ReActor-Nodes

CropFace

Precise face cropping

Same as above

VAELoader

Loads color-matching VAE

Built-in

PreviewImage

Real-time preview

Built-in


4. Workflow Groups

  1. Input Group

    • Target Image: Classical portrait (e.g., ygf.png).

    • Source Image: Modern face photo (e.g., girl_selfie.png).

  2. Preprocessing Group

    • Face Cropping: CropFace extracts facial regions.

    • VAE Loading: color101VAE_v1.pt ensures ancient-style skin tones.

  3. Face Swap Group

    • ReActor Config:

      • Model: inswapper_128.onnx

      • Enhancer: GFPGANv1.4 (strength=1)

      • Detector: retinaface_resnet50

  4. Output Group

    • VAE Decode: Restores image details.

    • Dual Preview: Swapped result + source face crop.


5. Inputs & Outputs

  • Required Inputs:

    • Target: Classical portrait (front-facing, ≥512x512).

    • Source: Modern face (clear features, simple background).

    • Params: face_boost=1, swap_model=inswapper_128.

  • Output:

    • Swapped image (retains target's clothing/background).

    • Source face crop (for debugging).


6. Notes

  1. Hardware:

    • ≥6GB VRAM (RTX 3060+ recommended), GFPGAN requires extra resources.

  2. Troubleshooting:

    • Misaligned faces: Switch detector to resnet50 (default mobile0.25 may fail).

    • Color mismatch: Try alternative VAEs or enable color_transfer.

  3. Model Paths:

    • Place inswapper_128.onnx in ComfyUI/models/insightface.