ComfyUI > Nodes > Facefusion_comfyui > FF API: Swap Face (Image)

ComfyUI Node: FF API: Swap Face (Image)

Class Name

SwapFaceImage

Category
FaceFusion API
Author
huygiatrng (Account age: 2009days)
Extension
Facefusion_comfyui
Latest Updated
2025-11-30
Github Stars
0.04K

How to Install Facefusion_comfyui

Install this extension via the ComfyUI Manager by searching for Facefusion_comfyui
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Facefusion_comfyui in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

FF API: Swap Face (Image) Description

Facilitates seamless face swapping in images using advanced detection and integration algorithms.

FF API: Swap Face (Image):

The SwapFaceImage node is designed to facilitate the process of face swapping between images, a popular technique in digital art and photo manipulation. This node allows you to seamlessly replace a face in a target image with a face from a source image, leveraging advanced face detection and swapping algorithms. The primary goal of this node is to provide a user-friendly interface for artists to create realistic and high-quality face swaps without needing deep technical knowledge. By utilizing various models and parameters, the node ensures that the swapped face integrates naturally with the target image, maintaining consistent lighting, color, and texture. This capability is particularly beneficial for creating unique artistic compositions, enhancing portraits, or generating creative content for social media and marketing.

FF API: Swap Face (Image) Input Parameters:

source_tensor

This parameter represents the image tensor containing the face you want to use for swapping. It is crucial as it provides the source face that will be transferred to the target image. The quality and resolution of this image can significantly impact the final result, so using a high-quality source image is recommended.

target_tensor

The target tensor is the image where the face swap will occur. This parameter is essential as it determines the context and background where the new face will be placed. The node processes this image to detect faces and apply the swap, ensuring the new face fits naturally within the scene.

api_token

An API token is required for authentication purposes when using external face swapping services. This parameter ensures that the node can securely access and utilize these services, if applicable, to perform the face swap operation.

face_swapper_model

This parameter specifies the model used for the face swapping process. Different models may offer varying levels of detail, speed, and accuracy, so selecting the appropriate model can influence the quality of the swap. The default model is typically optimized for general use.

pixel_boost

Pixel boost determines the resolution at which the face swap is processed. Higher values can lead to more detailed swaps but may require more computational resources. The default value is 512x512, balancing quality and performance.

face_mask_blur

This parameter controls the amount of blur applied to the face mask edges, helping to blend the swapped face with the target image. A default value of 0.3 is used, which provides a smooth transition without noticeable edges.

face_occluder_model

An optional parameter that specifies a model to handle occlusions, such as hair or glasses, during the face swap. Using an occluder model can improve the realism of the swap by accounting for these elements.

face_parser_model

This optional parameter allows for the use of a face parser model, which can enhance the swap by accurately identifying facial features and ensuring they align correctly in the target image.

face_selector_mode

Determines whether to swap one face or multiple faces in the target image. The default mode is one, which focuses on a single face, but you can choose many to swap all detected faces.

face_position

Specifies the position of the face to be swapped in the target image, useful when multiple faces are present. The default position is 0, indicating the first detected face.

sort_order

This parameter defines the order in which faces are processed, with options like large-small to prioritize larger faces. This can be useful in images with multiple faces to ensure the most prominent face is swapped first.

score_threshold

A threshold value for face detection confidence, set at 0.3 by default. This parameter helps filter out less confident detections, ensuring only clearly identified faces are considered for swapping.

face_detector_model

Specifies the model used for detecting faces in the images. The default model is scrfd, known for its accuracy and speed in face detection tasks.

face_mask_types

An optional list of mask types to apply during the swap, allowing for customization of the face mask used in the process. This can affect how the face is integrated into the target image.

face_mask_areas

Defines specific areas of the face mask to be used, providing further control over the swap process. This parameter is optional and can be tailored to achieve desired effects.

face_mask_regions

Similar to face mask areas, this optional parameter allows for the specification of regions within the face mask, offering additional customization for the face swap.

face_mask_padding

A tuple specifying padding around the face mask, with a default of (0, 0, 0, 0). Padding can help ensure the swapped face fits well within the target image, especially in cases of tight cropping.

FF API: Swap Face (Image) Output Parameters:

output_tensor

The output tensor is the final image with the face swap applied. This parameter is crucial as it represents the end result of the node's processing, showcasing the new face integrated into the target image. The quality and realism of this output depend on the input parameters and models used.

FF API: Swap Face (Image) Usage Tips:

  • Ensure that both source and target images are of high quality and resolution to achieve the best results.
  • Experiment with different face swapper models to find the one that best suits your artistic needs.
  • Use the face_mask_blur parameter to adjust the blending of the swapped face with the target image for a more natural look.
  • If multiple faces are present, use the face_position parameter to select the specific face you want to swap.

FF API: Swap Face (Image) Common Errors and Solutions:

No faces in face_data to swap

  • Explanation: This error occurs when no faces are detected in the target image.
  • Solution: Ensure that the target image contains clear and visible faces. Adjust the score_threshold parameter if necessary to improve face detection.

Face index out of range

  • Explanation: The specified face_position exceeds the number of detected faces in the target image.
  • Solution: Verify the number of faces detected and adjust the face_position parameter accordingly.

No faces detected in source image

  • Explanation: The source image does not contain any detectable faces.
  • Solution: Use a source image with clear and visible faces. Check the score_threshold parameter to ensure it is set appropriately for face detection.

FF API: Swap Face (Image) Related Nodes

Go back to the extension to check out more related nodes.
Facefusion_comfyui
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.