Mastering AI Portrait Editing: A Step-by-Step Workflow for Stunning Results

CN
ComfyUI.org
2025-06-11 09:35:59

1. Workflow Overview

mbrr88brjzfwkso5u5图片压缩854da20564a69dcfc6fcf6751778243038ab433d6d5d2f2f1cf929c096e65f6d.jpg

This workflow, named "AI Portrait Workflow", is designed for high-quality portrait generation and editing, integrating AI generation, face detection, inpainting, and style control.

  • Core Models:

    • Stable Diffusion XL (SDXL): LEOSAM HelloWorld _ SDXL_v7.0 (base model).

    • ControlNet: xinsir_union_promax.safetensors (pose/structure control).

    • IPAdapter: Style transfer and detail enhancement.

    • Florence-2: Face detection and segmentation.

  • Functions:

    • Automatic face detection and masking.

    • Multi-ControlNet integration (pose, depth, edges).

    • Background replacement and style fusion.

    • Low-strength inpainting for detail refinement.

2. Key Nodes

Node Name

Description

Installation

CheckpointLoaderSimple

Loads SDXL base model.

Download to models/checkpoints.

ControlNetLoader

Loads ControlNet models (pose/depth).

Place .safetensors in models/controlnet.

Florence2ModelLoader

Loads Florence-2 for face segmentation.

Install Florence-2 plugin.

IPAdapterUnifiedLoader

Loads IPAdapter for style transfer.

Install IPAdapter_Plus plugin.

Sam2Segmentation

Precise masking via SAM2.

Install Segment Anything plugin.

AIO_Preprocessor

Image preprocessing (e.g., edge detection).

Install AIO_Preprocessor nodes.

Image Comparer

Compares original vs. generated images.

Install rgthree plugin.

3. Workflow Structure

Key functional groups:

  1. Face Detection & Masking:

    • Florence2Run detects faces → Sam2Segmentation refines masks.

  2. ControlNet Control:

    • ControlNetApplySD3 applies pose/depth constraints.

  3. IPAdapter Style Transfer:

    • Transfers style from reference images (e.g., "Cyberpunk Girl").

  4. Inpainting & Refinement:

    • Light inpainting + PS masking for detail fixes.

4. Inputs & Outputs

  • Inputs:

    • Source image (e.g., portrait).

    • Optional prompts (default uses Florence-2 captions).

    • Control parameters (e.g., ControlNet weight).

  • Outputs:

    • Final portrait with stylized background.

    • Side-by-side comparisons via Image Comparer.

5. Notes

  • Model Dependencies:

  • Hardware:

    • ≥12GB VRAM (RTX 3080+), 24GB recommended for full pipeline.

  • Troubleshooting:

    • Poor masking: Adjust Sam2Segmentation bboxes or manual coordinates.

    • Over-stylization: Reduce weight in IPAdapterAdvanced (default: 0.7).