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.
Run it from TypeScript or Python with the Comfy SDK. The same code targets Comfy Cloud or a ComfyUI you host yourself — only the base URL changes.
// Install (beta)
npm i @comfyorg/sdk
// Run "Wan2.2 Animate: Automatic Character Replacement" (TypeScript)
import { Comfy } from "@comfyorg/sdk";
const client = new Comfy({ apiKey: "comfyui-..." });
// This workflow, exported in API format (see note below)
const wf = await client.workflows.fromFile("template_purz_wan22_animate_auto_character_replace_api.json");
const asset = client.assets.fromFile("input.png");
wf.setInput("10", "image", asset); // LoadImage
const job = await client.run(wf);
await job.getOutputs("19")[0].toFile("output.png"); // SaveVideoThe SDK takes a workflow in API format: open this workflow in ComfyUI and use File → Export Workflow (API).
Comfy Cloud API access requires a plan with an API key.
FAQ















