Batch Face Swap

Swaps faces / heads between two images in batch by compositing a source face onto a target scene. Semantics: face B is placed onto image A, where B is the source face and A is the target scene.

meitu batch image-face-swap

Note: Batch processing is available from meitu-cli v2.1.1 onward. Please upgrade if you're on an older version.

Usage Examples

# Scenario 1: Config file mode (batch face swap)
meitu batch image-face-swap \
  --config ./batch.face-swap.yaml \
  --output-dir ./outputs \
  --json

# Scenario 2: High-concurrency batch face swap
meitu batch image-face-swap \
  --config ./batch.face-swap.yaml \
  --output-dir ./outputs \
  --concurrency 3 \
  --max-retries 1 \
  --json-output ./result.json

Config File Example

version: 1
defaults:
  outputDir: ./outputs
items:
  - scene: ./scenes/man_in_suit.jpg
    head: ./faces/person1.jpg
    prompt: Natural face swap blending
  - scene: ./scenes/woman_dress.jpg
    head: ./faces/person2.jpg
    prompt: Natural face swap blending
  - scene: ./scenes/group_photo.jpg
    head: ./faces/person3.jpg
    prompt: Fine face swap, keep it natural

Parameter Reference

ParameterRequiredDescription
--output-dirYesOutput directory
--configYesPath to YAML/JSON config file (config file is required for batch face swap)
--concurrencyNoType: number; Default: 3; Number of concurrent executions
--max-retriesNoType: number; Default: 0; Number of retries on failure
--skip-existNoSkip existing output files
--dry-runNoPreview the plan without executing
--no-progressNoDisable per-task progress logging
--jsonNoOutput results in JSON format
--json-outputNoWrite results to a specified JSON file
--skill-nameNoSkill name attributed on the server side

Config Item Reference

Config ItemRequiredDescription
sceneYesPath to the target scene image (base image)
headYesPath to the source face image (the face provider)
promptYesDescription of the desired face swap effect