Nodes/comfyui-PD_comfy-api-node/PD 阿里云换脸(双图)
ComfyUI Node

PD 阿里云换脸(双图)

PD 阿里云换脸(双图)

By 7BEII·Created 9 months ago·Updated a day ago· 2
PD 阿里云换脸(双图)
  • template_image
  • face_image
  • 换脸结果

The one PD node that doesn't want your Comfy key

Every other node in the comfyui-PD_comfy-api-node pack works the same way: paste a ComfyUI API key, and it calls some closed model through Comfy's proxy. PD 阿里云换脸(双图)is the exception. It does a pixel-level face swap through Alibaba Cloud's facebody service directly, and the credential it needs is your Alibaba Cloud one - there is no comfy_api_key field anywhere on this node.

It's a post-process face swap in the same family as ReActor or ACE++ - take two images, transplant one face - but the heavy lifting happens on Alibaba's servers, not your GPU. If you already run a local swap pipeline you probably don't need this. If you'd rather not install the InsightFace stack, or you want the cloud's blend of the new face into the target lighting, this is the two-input wrapper.

How it works

Two images in, one image out. The node treats template_image as the base - the tooltip says it keeps the pose, expression and background - and face_image as the person whose facial features you're importing. Under the hood it calls Alibaba's AddFaceImageTemplate with the base, then MergeImageFace with the face image, downloads the merged result URL, and deletes the temporary template it created. Clean up included, which is more than most API wrappers bother with.

The endpoint is facebody.cn-shanghai.aliyuncs.com (region cn-shanghai), and the SDK picks up your credentials from the standard Alibaba default chain - ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables or a credentials file. You also need the FaceBody service enabled on the Alibaba account, and it's billed per call, so check pricing before you batch.

The inputs that matter

  • template_image - the base image. Its pose, expression and background survive.
  • face_image - the image supplying the new face.

Both are strictly single images: feed it a batch (a B x H x W x C tensor with batch size > 1) and it throws. The single output is the merged result, 换脸结果, a normal IMAGE you can wire into Save Image or anything downstream.

Installing and getting it running

The pack installs as one unit, and this node is the reason its requirements.txt exists at all:

cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/comfyui-PD_comfy-api-node.git
pip install -r comfyui-PD_comfy-api-node/requirements.txt

Restart ComfyUI and it appears under PD/API/阿里云 (not the usual PD_Tools menu). The requirements file carries exactly two packages - alibabacloud_credentials and alibabacloud_facebody20191230 - everything else it needs is already bundled with ComfyUI. ComfyUI Manager can also pull the pack if you search its title.

Common issues

  • "缺少阿里云 SDK" - you skipped the pip install -r step. Run it, restart.
  • Auth errors - the node silently relies on the credential chain. Set the env vars before starting the ComfyUI process, or the process won't see them.
  • "每个输入只支持一张图片" - you sent a batch to one of the image inputs. Single image per input, period.
  • Consent note - the author's own description reminds you to have authorization for both people in the photos. A cloud face swap sends both images to Alibaba's servers, so that's as much a privacy note as a legal one.

One thing to know going in: the result is whatever Alibaba's model decided, not a deterministic local render. Treat it as a cloud service with all the usual caveats - your images leave the machine, and the output lands when it lands.

CategoryPD/API/阿里云

Inputs (2)

NameTypeDefaultDescription
template_imageIMAGE保留姿势、表情和背景的底图
face_imageIMAGE提供新人物面部特征的人脸图

Outputs (1)

NameTypeDescription
换脸结果IMAGE