The 'Wan2.2 Animate: Automatic Character Replacement' workflow is designed to seamlessly replace a character in a video with a new character from an uploaded image. This is achieved using the Wan2.2 Animate model, which specializes in character animation and replacement. The workflow begins by loading your video and character image. It then processes these inputs through a series of nodes, including the ComfyUI-WanAnimatePreprocess for initial setup and the ComfyUI-segment-anything-2 for precise segmentation. This ensures that the character replacement is accurate and visually coherent.
Technically, the workflow leverages a combination of video processing nodes such as VHS_LoadVideo and VHS_VideoInfo to extract and manage video data. The b396d3e6-70cc-4a91-81db-6e0399a4edb6 node is crucial for handling complex data transformations required for character animation. By using these nodes in conjunction with the Wan2.2 Animate model, users can achieve high-quality character replacements that are both stable and realistic, especially when the reference image is a clear depiction of a human subject.
API
Use this workflow from code
Every Comfy workflow is a JSON graph. The payload below is this workflow, exactly as ComfyUI runs it — fetch it from the URL, keep it in version control, or load it in ComfyUI and run it node by node.
GET https://comfy.org/workflows/download/f49b24114ea9.jsonFetching workflow JSON…
Run it from Python or TypeScript with the Comfy SDK. The same code targets Comfy Cloud or a ComfyUI you host yourself — only the base URL changes.
# Install (beta)
pip install comfy-sdk # Python
npm i @comfyorg/sdk # TypeScript
# Run "Wan2.2 Animate: Automatic Character Replacement" (Python)
from comfy_sdk import Comfy
client = Comfy(api_key="comfyui-...")
# This workflow, exported in API format (see note below)
wf = client.workflows.from_file("template_purz_wan22_animate_auto_character_replace_api.json")
asset = client.assets.from_file("input.png")
wf.set_input("10", "image", asset) # LoadImage
job = client.run(wf)
for output in job.get_outputs("19"): # SaveVideo
output.to_file(output.name)The SDK takes a workflow in API format: open this workflow in ComfyUI and use File → Export Workflow (API). API access requires a Comfy Cloud plan with an API key. SDK docs · Get an API key
FAQ














