> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# ComfyUI SCAIL-2 Character Replacement Workflow Tutorial

> Drive a reference character image with a driving video for character animation or in-video character replacement using SCAIL-2.

**SCAIL-2** is an end-to-end character animation model built on Wan2.1. It drives a reference character image with a driving video, enabling both character animation (making a character perform the motion) and in-video character replacement (swapping a tracked person in a video with the reference character).

**Key Features**:

* **End-to-End Character Animation**: Drive a still character image with motion from a driving video
* **Two Modes**: Animation Mode (character performs the motion) and Replacement Mode (swap tracked person with reference character)
* **Long Video Support**: Chunk-based extended generation with frame overlap between segments
* **Built-in ComfyUI Nodes**: Uses native `WanSCAILToVideo`, `SCAIL2ColoredMask`, and `SAM3` tracking — no custom nodes required beyond standard model downloads

**Related Links**:

* [Hugging Face: SCAIL-2](https://huggingface.co/zai-org/SCAIL-2)
* [SCAIL-2 Diffusion Model](https://huggingface.co/Comfy-Org/SCAIL-2)

## SCAIL-2 Character Replacement Workflow

<CardGroup cols={2}>
  <Card title="Run in Comfy Cloud" icon="cloud" href="https://cloud.comfy.org/?template=video_wan21_scail2_character_replacement&utm_source=docs&utm_medium=referral&utm_campaign=scail2">
    Open in Comfy Cloud
  </Card>

  <Card title="Download Workflow" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/video_wan21_scail2_character_replacement.json">
    Download JSON or search "SCAIL-2" in Template Library
  </Card>
</CardGroup>

<Tip>
  <Tabs>
    <Tab title="Portable or self deployed users">
      Make sure your ComfyUI is updated.

      * [Download ComfyUI](https://www.comfy.org/download)
      * [Update Guide](/installation/update_comfyui)

      Workflows in this guide can be found in the [Workflow Templates](/interface/features/template).
      If you can't find them in the template, your ComfyUI may be outdated. (Desktop version's update will delay sometime)

      If nodes are missing when loading a workflow, possible reasons:

      1. You are not using the latest ComfyUI version (Nightly version)
      2. Some nodes failed to import at startup
    </Tab>

    <Tab title="Desktop or Cloud users">
      * The Desktop is base on ComfyUI stable release, it will auto-update when there is a new Desktop stable release available.
      * [Cloud](https://cloud.comfy.org) will update after ComfyUI stable release.

      So, if you find any core node missing in this document, it might be because the new core nodes have not yet been released in the latest stable version. Please wait for the next stable release.
    </Tab>
  </Tabs>
</Tip>

## How the Workflow Works

This workflow uses two subgraph nodes — a **Base** subgraph (first segment) and an **Extend** subgraph (subsequent segments) — to support character animation for both short and long videos.

1. **Load** a driving video (`pose_video`) and a reference character image
2. **Base subgraph** processes the first segment (81 frames by default)
3. **Extend subgraph** processes additional segments 2+, chaining `previous_frames` from the prior segment
4. Preview the result and save

<Card title="Learn about Subgraph" icon="book-open" href="/interface/features/subgraph">
  This workflow uses Subgraph nodes for modular processing. Check out the Subgraph documentation to learn how to customize and extend the workflow.
</Card>

### Long Videos

For longer videos, calculate the number of segments: `ceil(total_frames / 76)`. Each segment except the first uses the Extend subgraph. Duplicate the Extend node for more segments, chain the `previous_frames` output, and increment `segment_index`.

> **Note:** `WanSCAILToVideo` cannot queue all segments automatically — run each segment manually.

## Two Modes

| Mode            |  `replace_mode`  | Driving Mask BG | Summary                                                                   |
| --------------- | :--------------: | :-------------: | ------------------------------------------------------------------------- |
| **Replacement** | `true` (default) |      White      | Swap the tracked person in the driving video with the reference character |
| **Animation**   |      `false`     |      Black      | Reference character performs the driving motion                           |

Set the `replace_mode` parameter on both subgraph nodes.

## Inputs and Parameters

### Shared Parameters (Base & Extend)

| Parameter                                   | Description                                                                  |
| ------------------------------------------- | ---------------------------------------------------------------------------- |
| `pose_video`                                | The driving video containing motion to transfer                              |
| `reference_image`                           | The character image to animate or insert                                     |
| `prompt`                                    | Output video description                                                     |
| `replace_mode`                              | `true` = Replacement, `false` = Animation                                    |
| `segment_index`                             | `1` for first chunk, `2+` for continuation. Pose offset = `76 × (index − 1)` |
| `width` / `height`                          | Output resolution, e.g. `896×512`. Must be divisible by 16                   |
| `frame_count`                               | Frames per segment (default: 81)                                             |
| `previous_frame_count`                      | Overlap frames between segments (default: 5)                                 |
| `pose_strength` / `pose_start` / `pose_end` | Pose conditioning strength and timing                                        |

### SAM3 Tracking (two inputs)

The `sam3_video_object` and `sam3_image_object` inputs control the SAM3 mask tracking — **not** the SCAIL-2 output prompt. These determine which objects are tracked for the colored masks:

| Input               | Target          | Output                 |
| ------------------- | --------------- | ---------------------- |
| `sam3_video_object` | Driving video   | `pose_video_mask`      |
| `sam3_image_object` | Reference image | `reference_image_mask` |

* Use open-vocabulary text (default: `human`)
* Use the same term when the subject is the same across video and reference
* Use different terms if the video and reference need different focus (e.g., crowded scenes)

## Model Installation

Update ComfyUI to the latest version first for the built-in WanSCAILToVideo and SCAIL2ColoredMask nodes.

### Required Models

**diffusion\_models**

* [wan2.1\_14B\_SCAIL\_2\_fp16.safetensors](https://huggingface.co/Comfy-Org/SCAIL-2/resolve/main/diffusion_models/wan2.1_14B_SCAIL_2_fp16.safetensors)

**text\_encoders** (choose one)

* [umt5\_xxl\_fp8\_e4m3fn\_scaled.safetensors](https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors)

**clip\_vision**

* [clip\_vision\_h.safetensors](https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/clip_vision/clip_vision_h.safetensors)

**vae**

* [Wan2\_1\_VAE\_bf16.safetensors](https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan2_1_VAE_bf16.safetensors)

**loras**

* [lightx2v\_I2V\_14B\_480p\_cfg\_step\_distill\_rank64\_bf16.safetensors](https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors)
* [wan2.1\_SCAIL\_2\_DPO\_lora\_bf16.safetensors](https://huggingface.co/Comfy-Org/SCAIL-2/resolve/main/loras/wan2.1_SCAIL_2_DPO_lora_bf16.safetensors)

**checkpoints**

* [sam3.1\_multiplex\_fp16.safetensors](https://huggingface.co/Comfy-Org/sam3.1/resolve/main/checkpoints/sam3.1_multiplex_fp16.safetensors)

### File Storage Locations

```
ComfyUI/
├── models/
│   ├── diffusion_models/
│   │   └── wan2.1_14B_SCAIL_2_fp16.safetensors
│   ├── text_encoders/
│   │   └── umt5_xxl_fp8_e4m3fn_scaled.safetensors
│   ├── clip_vision/
│   │   └── clip_vision_h.safetensors
│   ├── vae/
│   │   └── Wan2_1_VAE_bf16.safetensors
│   ├── loras/
│   │   ├── lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors
│   │   └── wan2.1_SCAIL_2_DPO_lora_bf16.safetensors
│   └── checkpoints/
│       └── sam3.1_multiplex_fp16.safetensors
```
