图片换脸V5

namifusion/faceswap-v5

NamiFusion Faceswap v5 是兼具极致速度与高性价比的换脸模型,支持智能色调匹配,专为需要高并发、实时处理且追求专业画质的规模化生产而设计。

示例

图片换脸V5 example 1

参数

名称类型默认约束说明
source_image源图像 (人脸)image_upload0–1 items
target_image目标图像 (背景/场景)image_upload0–1 items
additional_prompt附加提示词textarea
image_format输出格式selectjpegpng | jpeg | webp
quality图像质量slider9510 ~ 100 · step 1
seed随机种子number8005332

输出字段

字段类型说明
imagesarray<string>

API

通过统一 REST API 调用本模型;在 API Keys 页获取密钥。

cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "source_image": [
      "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
    ],
    "target_image": [
      "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
    ],
    "image_format": "jpeg",
    "quality": 95,
    "seed": 8005332
  }
}'

# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
  -H "Authorization: Bearer YOUR_API_KEY"
Python
import time, requests

API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

# 1) Submit
resp = requests.post(
    "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5",
    headers=HEADERS,
    json={
        "input": {
            "source_image": [
                "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
            ],
            "target_image": [
                "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
            ],
            "image_format": "jpeg",
            "quality": 95,
            "seed": 8005332
        }
    },
)
resp.raise_for_status()  # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()

# 2) Poll until a terminal state (completed / failed / cancelled).
#    This model is allowed up to 300s server-side.
deadline = time.time() + 360
while task.get("status") not in ("completed", "failed", "cancelled"):
    if time.time() > deadline:
        raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
    time.sleep(3)
    poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
    poll.raise_for_status()
    task = poll.json()

print(task["status"], task.get("output"))
JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };

// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5", {
  method: "POST",
  headers: { ...HEADERS, "Content-Type": "application/json" },
  body: JSON.stringify({
    "input": {
      "source_image": [
        "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
      ],
      "target_image": [
        "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
      ],
      "image_format": "jpeg",
      "quality": 95,
      "seed": 8005332
    }
  }),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();

// 2) Poll until a terminal state (completed / failed / cancelled).
//    This model is allowed up to 300s server-side.
const deadline = Date.now() + 360 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
  if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
  await new Promise((r) => setTimeout(r, 3000));
  const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
  if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
  task = await poll.json();
}

console.log(task.status, task.output);

文档

NamiFusion Faceswap v5

AI 图片换脸 v5:超高速人脸与智能换头,内置肤色匹配,专为高并发生产级工作流设计。

NamiFusion Faceswap v5 是一款面向速度与规模的图片换脸 API。它在保持与 Faceswap v2 同等推理速度的同时,大幅提升了输出质量,具备自动智能换头、内置肤色匹配和创意提示词支持——且是 NamiFusion 换脸系列中成本最低的选项。


核心特性

  • 超高速推理: 与 Faceswap v2 速度持平,同时输出质量显著提升。
  • 智能换头: 自动判断使用仅换脸还是整头融合,以获得最自然的效果——无需手动选择模式。
  • 内置肤色匹配: 自动适配肤色,无需手动校色即可获得自然无缝的结果。
  • 创意提示词支持: 使用 additional_prompt 引导细微属性变化,例如"戴帽子"或"微笑"。
  • 可复现输出: 基于 seed 的生成机制确保每次运行结果一致,非常适合 A/B 测试和批量工作流。
  • 成本优化: NamiFusion 换脸系列中最实惠的选项,不牺牲专业级输出质量。

技术规格

参数详情
核心输入字段source_imagetarget_imageseed
可选字段additional_promptimage_formatquality
图片格式选项pngjpegwebp
质量范围10 – 100(默认:95
Seed 默认值8005332
平均推理时间~9.63s

快速开始

API 端点

端点方法描述
/api/v1/marketplace/run/namifusion/faceswap-v5POST提交 Faceswap v5 任务(同步)

Faceswap v5 采用同步响应模式——结果直接在响应体中返回,无需轮询。

请求参数概览

请求体中 Faceswap v5 的核心字段如下:

{
  "source_image": "string(URL)",
  "target_image": "string(URL)",
  "additional_prompt": "string",
  "image_format": "png | jpeg | webp",
  "quality": 95,
  "seed": 8005332
}

鉴权

在请求头中携带您的 API Key:

X-API-Key: sk-your-api-key

标准调用流程

Faceswap v5 采用同步工作流——结果图片直接返回:

  1. 携带输入参数调用 POST /api/v1/marketplace/run/namifusion/faceswap-v5
  2. 响应体中直接包含结果图片。
  3. 无需轮询步骤。

提交任务并获取结果

curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5" \
  -H "X-API-Key: sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "source_image": "https://example.com/source.jpg",
      "target_image": "https://example.com/target.jpg",
      "image_format": "png",
      "quality": 95,
      "seed": 8005332
    }
  }'

成功响应示例:

{
  "status": "completed",
  "output": {
    "image_url": "https://cdn.namifusion.com/result/faceswap_v5_abc123.png"
  }
}

失败响应示例:

{
  "status": "failed",
  "output": null,
  "error_message": "Face swap failed because no valid face was detected in source_image."
}

场景一:基础换脸(最少参数)

适用于快速测试或简单的单人换脸场景,使用默认质量和格式即可满足需求。

请求示例

{
  "source_image": "https://example.com/source.jpg",
  "target_image": "https://example.com/target.jpg"
}

行为说明

  • image_format 默认为 png
  • quality 默认为 95
  • seed 默认为 8005332
  • 智能换头自动运行——无需选择模式。
  • 内置肤色匹配始终生效。

场景二:生产级换脸(完整参数)

适用于生产流水线、营销活动或内容创作,对输出格式、质量和可复现性有明确要求的场景。

请求示例

{
  "source_image": "https://example.com/source_face.jpg",
  "target_image": "https://example.com/target_person.jpg",
  "additional_prompt": "wearing a hat",
  "image_format": "jpeg",
  "quality": 95,
  "seed": 2023
}

行为说明

  • additional_prompt 引导输出中的细微属性变化(如配饰、表情等)。
  • image_format: "jpeg" 生成更小的文件,适合 Web 分发。
  • quality: 95 确保生产级输出保真度。
  • 固定 seed 保证相同输入下每次调用结果完全一致。

场景三:高并发批量处理(速度优先)

适用于自动化流水线、数据集匿名化或实时应用,吞吐量和成本优先于最高质量的场景。

请求示例

{
  "source_image": "https://example.com/source.jpg",
  "target_image": "https://example.com/target.jpg",
  "image_format": "webp",
  "quality": 75,
  "seed": 42
}

行为说明

  • quality: 75 在保持可接受视觉质量的同时,减少处理时间和输出体积。
  • image_format: "webp" 在 Web 规模分发中提供最佳的压缩与质量平衡。
  • 批量运行中保持一致的 seed,确保可复现输出,便于缓存和 A/B 测试。

参数与返回值详情

请求参数

参数类型必填默认值描述
source_imagestring提供人脸身份的源图片 URL。
target_imagestring需要替换人脸的目标图片 URL。
additional_promptstring""用于细微属性引导的简短描述性提示词(如 "wearing a hat""smiling")。
image_formatstring"png"输出图片格式。可选值:"png""jpeg""webp"
qualityinteger95输出质量,范围 10100。值越高,保真度越好,文件越大。
seedinteger8005332用于可复现性的随机种子。相同输入下使用相同 seed 可获得完全一致的输出。

校验规则与常见错误

source_image / target_image

  • 必须是可公开访问的 URL。
  • source_image 中的人脸提供身份;target_image 中的人脸是被替换的对象。
  • 建议使用面部特征清晰可见的正面图片以获得最佳效果。

additional_prompt

  • 保持提示词简短且具描述性(如 "wearing sunglasses""different hairstyle")。
  • 避免长而复杂的提示词——v5 针对细微、可控的变化进行了优化。
  • 不需要属性修改时留空即可。

image_format

  • 可选值:"png""jpeg""webp"
  • 推荐使用 jpeg 以获得最快处理速度和最小文件体积。
  • 需要最高细节或后期编辑灵活性时推荐使用 png
  • webp 提供质量与压缩的最佳平衡。

quality

  • 整数,范围 10100
  • 推荐:生产和最终资产使用 95;快速测试和迭代使用 75–85

参数对输出的影响

参数组合对结果的影响
quality: 95生产级保真度;文件较大。
quality: 75–85处理更快,文件更小;适合测试。
image_format: "jpeg"处理最快,文件最小。
image_format: "png"最高细节;最适合后期编辑。
image_format: "webp"Web 分发的最佳质量体积比。
提供 additional_prompt引导换脸输出中的细微属性变化。
additional_prompt 为空不进行属性修改;纯人脸/整头替换。
固定 seed相同输入下每次调用输出完全一致。
随机 seed每次运行输出略有差异。

按使用场景推荐配置

使用场景qualityimage_formatseedadditional_prompt
内容创作(缩略图、社交媒体)85webp1001"wearing sunglasses"
营销广告(活动素材)95jpeg2023"different hairstyle"
隐私保护(数据集匿名化)90png31415(留空)
实时 / 高并发批量处理75jpegwebp42(留空)

注意事项

  1. 智能换头始终开启: Faceswap v5 自动决定使用仅换脸还是整头融合——无需任何配置。
  2. 肤色匹配内置: 模型自动适配肤色,几乎不需要手动颜色校正。
  3. 保持图片姿态基本一致: 源图和目标图的头部角度与光线条件相近时,效果最自然。
  4. 使用固定 seed 保证一致性: A/B 测试、缓存和批量流水线中,锁定 seed 以确保可复现输出。
  5. 优先使用可公开访问的 URL: 这有助于服务稳定地获取图片资源。
  6. 避免复杂提示词: additional_prompt 设计用于简短、细微的属性提示,而非详细的场景描述。