Nodes/ComfyUI-FeiHou-Toolbox/Create SCAIL-2 Colored Mask V2
ComfyUI Node

Create SCAIL-2 Colored Mask V2

SCAIL-2's support masks, rendered for you (plus a prefix bonus)

By FX-FeiHou·Created 2 months ago·Updated 4 days ago· 127
Create SCAIL-2 Colored Mask V2
  • driving_track_data
  • ref_track_data
  • prefix_track_data
  • pose_video_mask
  • reference_image_mask
  • prefix_image_mask
object_indices
sort_byleft_to_right
prefix_mask_modeMulti Image Single Color
replacement_modefalse
render_devicegpu

SCAIL-2, Z.ai's motion transfer model, made its name by throwing out the pose skeleton entirely. It takes three things: a reference image, a driving video, and support masks that tell it which tracked object is which. Those colored masks are exactly what this node produces - it's a beefed-up copy of ComfyUI's built-in SCAIL-2 colored mask node, with a prefix image mask output added on top. If you're building a SCAIL-2 workflow with multi-character or multi-reference support, this is the node that renders the colored input masks those workflows need.

The KB's SCAIL-2 panel puts the context on it: a Wan 2.1-base model that does cross-identity replacement, animal driving, and zero-shot multi-reference, at the price of real compute. The colored masks are the plumbing that makes the "which character is which" part work - each tracked person gets a palette color, and the model reads identity and motion from how those colors move.

How it works

Everything comes in as SAM3_TRACK_DATA - the packed mask tracks produced by ComfyUI's SAM3 tracking nodes. The node takes three of them and renders each into its own colored mask output:

  • driving_track_data (required) - the SAM3 track of your driving pose video, rendered frame-by-frame into pose_video_mask.
  • ref_track_data (optional) - the track of your reference image, rendered to reference_image_mask.
  • prefix_track_data (optional) - the track of a prefix image batch; the first 5 frames become prefix_image_mask. This prefix output is the node's headline addition over ComfyUI core's version - it's how you feed multi-reference identity frames in.

Colors are assigned per tracked object. sort_by decides the order - left_to_right gives the first color to the leftmost person, area to the biggest, none keeps SAM3's own order. object_indices is a comma-separated filter (0,2,3) that keeps only those people, applied across all three outputs; empty means everyone.

replacement_mode flips the whole background scheme: false = Animation Mode (pose_video_mask on black, reference and prefix masks on white), true = Replacement Mode (inverted - driving on white, refs on black). Get these backwards and SCAIL-2 reads the scene wrong, so keep an eye on it.

prefix_mask_mode controls how the prefix batch is colored: Multi Image Single Color (each frame one color matching the reference foreground), Multi Image Multi Color (per-object palette colors), or Single Image Multi Color (batch-order colors - blue, red, green, magenta, cyan, then looping after five).

The output that matters

Three IMAGE outputs, all wired into SCAIL-2's mask inputs downstream: pose_video_mask (from the driving track), reference_image_mask (from the ref track), prefix_image_mask (from the prefix track's first 5 frames). If you don't connect prefix_track_data, the node logs a warning and hands back a blank prefix mask - a silent-looking failure that will confuse a SCAIL-2 run if you miss it.

Install and the VRAM trade

ComfyUI Manager (search ComfyUI-FeiHou-Toolbox) or:

cd ComfyUI/custom_nodes
git clone https://github.com/FX-FeiHou/ComfyUI-FeiHou-Toolbox

Restart, hard-refresh the browser. No extra Python deps, but it needs a current ComfyUI (the pack uses the newer comfy_api.latest node API) and SAM3 checkpoint + track setup upstream. render_device defaults to gpu for speed; if a long driving video runs your VRAM dry, switch it to cpu to offload mask rendering to system memory - slower, but it keeps the rest of the SCAIL-2 pipeline alive. That's the author's own fallback, per the changelog.

One licensing footnote carried over from the KB: SCAIL-2 itself is Apache 2.0, but SAM3 (the thing producing your tracks) is under Meta's custom SAM License. Different terms, same pipeline.

Categoryconditioning/video_models/scail

Inputs (8)

NameTypeDefaultDescription
driving_track_dataSAM3_TRACK_DATASAM3 track of the driving pose video. Will be rendered into the pose_video_mask output.
object_indicesSTRINGComma-separated list of person indices to include (e.g. '0,2,3'). Applied to driving, reference, and prefix masks. Empty = all.
sort_byCOMBOleft_to_rightOrder in which palette colors are assigned to tracked objects. left_to_right = leftmost object gets the first color; area = biggest object gets the first color; none = keep SAM3's order.
prefix_mask_modeCOMBOMulti Image Single ColorMulti Image Single Color = each output batch image is single-color matching the reference_image_mask foreground color. Multi Image Multi Color = each batch image uses object colors by the node palette rule. Single Image Multi Color = single-color output by batch order: blue, red, green, magenta, cyan, then loop.
replacement_modeBOOLEANfalseFalse = Animation Mode (pose_video_mask black background, reference_image_mask and prefix_image_mask white background). True = Replacement Mode (pose_video_mask white background, reference_image_mask and prefix_image_mask black background).
render_deviceCOMBOgpugpu renders masks on the graphics card for speed. cpu offloads mask rendering to system memory to reduce VRAM use.
ref_track_dataoptSAM3_TRACK_DATASAM3 track of the reference image.
prefix_track_dataoptSAM3_TRACK_DATASAM3 track of a prefix image batch. The first 5 frames are rendered into prefix_image_mask.

Outputs (3)

NameTypeDescription
pose_video_maskIMAGE
reference_image_maskIMAGE
prefix_image_maskIMAGE