Skip to content

[feat] canvas: character replacement as a node workflow (mask, depth, composite, FastH3 structure control) - #479

Merged
princepride merged 2 commits into
mainfrom
feat/character-replacement-node-workflow
Nov 24, 2026
Merged

princepride merged 2 commits into
mainfrom
feat/character-replacement-node-workflow

Conversation

@princepride

Copy link
Copy Markdown
Collaborator

Summary

Person or costume replacement in a video becomes a chain of canvas nodes, each one inspectable and re-runnable, instead of one opaque tool:

source video ─ 视频抠像 (SAM 3, new 遮罩 output) ──────────┐
             └ 深度动作捕捉 (Video Depth Anything) ─ 遮罩合成 ─┐
reference image ─────────────────────────────────── FastH3 video node (结构控制)
  • Mask output for video matting. video-matting accepts background=mask and returns white tracked objects on black.
  • New local tool video-mask-composite (遮罩合成). It keeps the first video inside the white area of the second and makes everything else black. Optionally it stretches the masked brightness to 50..255, so a person's depth uses the full control range. Results draw provenance edges from both the content node and the mask node.
  • FastH3 structure control. FastH3 video nodes gain videoMode=control (结构控制) with a new reference role, control.
    • The one connected video is sent as control_reference with control_type=depth (Fun ControlNet). Images stay Ref2VA references.
    • The output follows the control video: the longest 17n+5 frame count it covers, the nearest H3 768P/480P bucket, and long_video_mode=full beyond one window. The allowed range is 4–30 s.
    • The control clip is not a <Video N> reference and does not count toward the 15 s reference budget.
  • Frontend.
    • 结构控制 mode in the composer, plus a 跟随控制视频 toggle in the duration popover.
    • The control role and its validation in rules.
    • A mask picker and the stretch option in the video tool panel.
    • i18n strings, and regenerated contracts and rule facts.

Control needs a FastH3 server started with the Fun ControlNet, i.e. TP8 and --controlnet-model-path (vllm-project/vllm-omni#10958). Control cannot be combined with continuation, so structure-control output is capped at 30 s.

Linked issue

  • No issue applies

Labels

  • Labels applied (type:feat, area:canvas, area:provider, modality:video)

Test plan

  • Local:
    • npm test: 963 passed.
    • npx tsc --noEmit, vite build, npm run check:i18n, npm run check:browser-manifest and scripts/generate_contracts.py --check all pass.
    • python -m pytest tests -k "not live": 2875 passed, 112 skipped.
    • New or extended tests:
      • tests/test_fasth3_inputs.py: control parameters (bucket, 17n+5 frames, long_video_mode=full) and the request fields.
      • tests/test_tool_tasks.py: mask background and mask composite.
      • tests/test_rule_facts.py, tests/backendRules.test.ts: control-mode rules and the Python and TypeScript rule mirrors.
      • tests/toolCatalog.test.ts, tests/canvasLinkedResults.test.ts: the tool entry and the two-parent provenance edges.
      • tests/browser/composer_duration.mjs: the 跟随控制视频 toggle.
  • Left to CI: lint-imports (not installed locally) and the browser lanes, including the updated composer_duration journey.

Evidence that it works

  • Run end to end on real models; screenshots to be added in a comment.
    • A scripted run of the whole chain on a 25 s dance clip: SAM 3 mask, then VDA Large depth, then 遮罩合成, then FastH3 structure control with a costume reference image. Every node produced its output.
    • The deployed build was used from the canvas UI for several 25 s, 768×1344 structure-control generations. Each was 600 frames with control_type=depth, and all succeeded.

Provider verification

  • Real self-hosted vLLM-Omni services were used: SAM 3, Video Depth Anything Large, and FastH3 Omni at TP8 with MiniMax-H3-Fun-Controlnet-Union. No hosted provider was called. Not verified: 480P control output and outputs longer than 25 s.

Bilingual UI

  • All new strings ship in both zh-CN and en-US.

🤖 Generated with Claude Code

… composite, FastH3 structure control)

Builds person/costume replacement from canvas nodes instead of one opaque
tool:

  source video ─ 视频抠像 (SAM 3, new 遮罩 output) ──────────┐
               └ 深度动作捕捉 (Video Depth Anything) ─ 遮罩合成 ─┐
  reference image ─────────────────────────────────── FastH3 视频节点 (结构控制)

- video-matting gains background=mask: white tracked objects on black.
- video-mask-composite (遮罩合成, local): keeps the first video inside the
  white area of the second, black elsewhere; optionally stretches the
  masked brightness to 50..255 so a person's depth uses the full control
  range. Its results draw provenance edges from both the content and the
  mask node.
- FastH3 video nodes gain videoMode=control (结构控制) with reference role
  control: the one connected video is sent as control_reference with
  control_type=depth (Fun ControlNet), images stay Ref2VA references, and
  the output follows the control video: longest 17n+5 frames it covers,
  nearest H3 768P/480P bucket, long_video_mode=full beyond one window,
  4-30 s. The control clip is not a <Video N> reference and is exempt from
  the 15 s reference budget.
- Frontend: 结构控制 mode in the composer and a 跟随控制视频 toggle in the
  duration popover, control role/validation in rules, mask picker and
  stretch option in the video tool panel, i18n, regenerated contracts and
  rule facts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride princepride added area:canvas Canvas, nodes and direct manipulation area:provider Model providers and generation protocols modality:video Video generation, editing or rendering type:feat New capability or behaviour labels Nov 24, 2026
Mask composite pairs content and mask frames by index. A mask with another
frame rate or length (not made from the same source clip) drifted off the
person silently and was truncated to the shorter clip. It now fails with a
clear message when the frame rates differ or the frame counts differ by more
than one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride
princepride merged commit 51dedd7 into main Nov 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:canvas Canvas, nodes and direct manipulation area:provider Model providers and generation protocols modality:video Video generation, editing or rendering type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant