Multi-Frame Anchor Support for WanImageToVideoSVIPro - #495
Open
diodiogod wants to merge 3 commits into
Open
Conversation
- Fix hardcoded batch size (1 -> B) in padding and mask creation - Add anchor_frame_count parameter for experimental multi-frame anchoring - Add StandardLatentToWanVideoLatent utility node for batch-to-temporal conversion - Handle negative padding edge cases
More descriptive name that clearly indicates batch-to-temporal dimension conversion
- Remove unused frames_per_image parameter that was confusing and not working - Simplify to pure batch→temporal conversion: [B,C,H,W] → [1,C,B,H,W] - Users control frame distribution by arranging images in batch before encoding - Update descriptions and examples to reflect actual usage pattern
Author
AnimateDiff_00070.mp4 |
Author
|
Workflow for reference, its a big workflow, it has many custom nodes, many nodes that if from forks I did... anyway. Just for reference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Multi-Frame Anchor Support for WanImageToVideoSVIPro
Background & Exploration
I started exploring whether the
anchor_samplesinWanImageToVideoSVIProcould accept multiple images as references, similar to how IP-Adapter works for image generation. Through testing with Claude Code, I discovered that:anchor_frame_count=1)While experimenting with the
anchor_frame_countparameter to mask multiple frames, I found that masking only the first frame (default behavior) works best. Settinganchor_frame_count > 1causes blending artifacts where multiple anchor frames visually merge in the output.The sweet spot: Using a multi-frame anchor with
anchor_frame_count=1(mask only first frame) allows the reference image to influence generation without artifacts.What This PR Fixes
Critical Bug: Hardcoded Batch Size
The original
WanImageToVideoSVIProhad hardcodedbatch_size=1assumptions that caused dimension mismatch errors when trying to use multi-frame anchors:Before:
After:
New Feature:
anchor_frame_countParameter1(recommended - standard SVI Pro behavior)anchor_samplesare marked as anchor in the maskprev_samplesis not connectedNew Utility:
BatchLatentToWanVideoLatentThe second issue was no way to properly format multi-image latents for use as anchors.
The Problem:
The Solution:
Node Features:
[B, C, H, W] → [1, C, B, H, W]Use Cases & Testing
Reference-Based Video Generation (IP-Adapter-like)
Using a
1+Nconfiguration (1 reference + N repeated starting frames):I will post video examples demonstrating:
1+4frames (reference + 4 start frames)1+8frames1+12frames1+20frames1+40framesEach configuration shows different levels of reference influence on the generated video.
Needs more testing but could be good for:
Known Limitations & Workarounds:
1+Nratio (needs more testing) - Lower N (e.g.,1+4) appears to cause more noticeable color bleeding than higher N (e.g.,1+20,1+40)Workarounds:
Use ColorMatch node - Apply color matching between reference and starting image before encoding
Crude montage technique - Manually composite elements from reference onto the starting frame:
Example:
Multi-Frame Anchor Experiments
Tried using
anchor_frame_count > 1to mask multiple frames as anchors:anchor_frame_count=1for best resultsRelation to PR #474
This PR shares one fix with PR #474 (by @siraxe):
batch_size=1bug in padding/mask creationend_frame_latent,end_frame_fill,end_frame_max_strength)anchor_frame_countparameter for controllable multi-frame maskingBatchLatentToWanVideoLatentutility nodeThe fixes are compatible and could potentially be merged together.
Technical Details
Batch-to-Temporal Conversion
Wan VAE batch encoding creates:
[B, C, T=1, H, W]where each item is a separate single-frame video.For multi-frame anchors, we need:
[1, C, T=B, H, W]where frames are in temporal dimension.The
BatchLatentToWanVideoLatentnode:[B, C, H, W]from standard VAE[1, C, B, H, W]video formatSimple and straightforward - users control frame distribution by arranging images in the batch before encoding.
Files Changed
nodes/nodes.py:WanImageToVideoSVIProbatch size hardcodinganchor_frame_countparameterBatchLatentToWanVideoLatentnode (new)__init__.py:BatchLatentToWanVideoLatentBackwards Compatibility
✅ Fully backwards compatible
anchor_frame_count=1)Example Workflow
Before (Broken):
After (Fixed):
Checklist
Notes for Reviewers
The core bug fix is simple (changing
1toB), but it enables a previously impossible workflow. TheBatchLatentToWanVideoLatentnode is the proper way to format multi-image latents for this use case.The reference-based generation technique creates an IP-Adapter-like effect for video generation, which is particularly useful since Wan models don't have native IP-Adapter support (? I think, we have wan fun vace, but it's a full other model, while this is a lora).
Note on anchor_frame_count: While the parameter allows experimental multi-frame masking, testing shows that keeping it at
1(default) produces the best results. Values > 1 cause blending artifacts.cc: @kijai (original author of WanImageToVideoSVIPro)
cc: @siraxe (PR #474 - related batch size fix)