PiAPI Image Faceswap (Single & Multi-Face) icon

PiAPI Image Faceswap (Single & Multi-Face)

Swap one or multiple faces in images with precise face index control using PiAPI Faceswap API

Overview

This node enables swapping one or multiple faces between two images using the PiAPI Faceswap API. It supports precise control over which faces to swap by allowing users to specify face indices, making it suitable for scenarios where multiple faces appear in images and selective swapping is desired.

Common use cases include:

  • Replacing faces in group photos with faces from other images.
  • Creating fun or creative image edits by swapping specific faces.
  • Automating face replacement tasks in image processing workflows.

For example, you can input a target group photo and a swap image containing faces to replace specific individuals in the target photo by specifying their face indices.

Properties

Name Meaning
Multi-Face Support Notice informing that the node supports swapping multiple faces and that advanced options allow specifying face indices.
Target Image Input Method Method to provide the target image: either via URL or binary data.
Target Image Binary Property (If binary data selected) Name of the binary property containing the target image data.
Target Image URL (If URL selected) URL of the target image where faces will be replaced.
Swap Image Input Method Method to provide the swap image: either via URL or binary data.
Swap Image Binary Property (If binary data selected) Name of the binary property containing the swap image data.
Swap Image URL (If URL selected) URL of the image containing the face(s) to swap into the target image.
Enable Multi-Face Selection Boolean to enable manual selection of specific faces by index for both target and swap images.
Face Indices Information Notice shown when multi-face selection is enabled, explaining typical face detection order (left to right, or top-left to bottom-right).
Swap Faces Index (If multi-face selection enabled) Comma-separated string of face indices to use from the swap image (e.g., "0" or "0,1").
Target Faces Index (If multi-face selection enabled) Comma-separated string of face indices to replace in the target image (e.g., "0" or "0,1").
Wait For Completion Boolean indicating whether the node should wait for the face swap process to complete before continuing execution.
Max Retries (If waiting for completion) Maximum number of retries to check the task status.
Retry Interval (If waiting for completion) Interval in milliseconds between retries checking the task status.

Output

The node outputs JSON data representing the status or result of the face swap task:

  • When not waiting for completion, the output contains the task ID and current status (usually "pending").
  • When waiting for completion, the output includes the final task status and any relevant data returned by the API upon completion.

The output does not directly contain the swapped image but provides information to retrieve or confirm the processed image from the API.

No binary data output is produced by this node.

Dependencies

  • Requires an API key credential for the PiAPI Faceswap service.
  • Uses the PiAPI Faceswap API endpoint /api/v1/task with model "Qubico/image-toolkit" and task types "face-swap" or "multi-face-swap".
  • The node expects images to be accessible via URLs or provided as binary data within the workflow.
  • If binary data is used, the node validates that the data is an image MIME type.

Troubleshooting

  • Invalid image data: If the provided binary data is not an image, the node throws an error indicating invalid image data.
  • Failed to get valid image: If the API cannot process the image (e.g., inaccessible URL, unsupported format, or too large resolution), the node returns a clear error message advising to check image accessibility, format (JPEG, PNG), and size (under 2048x2048).
  • Task ID missing: If the API response does not include a task ID, the node throws an error indicating failure to obtain a valid task ID.
  • Timeouts or long waits: When waiting for completion, if the maximum retries are exceeded without task completion, the node may return incomplete status; adjusting retry count and interval can help.
  • Use the "Continue On Fail" option to handle errors gracefully and continue processing subsequent items.

Links and References

Discussion