[MAX] Add Wan-Animate pipeline support#6347
Draft
kkimmk wants to merge 16 commits intomodular:mainfrom
Draft
Conversation
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
- simple_offline_video_generation.py: standalone T2V/I2V example with profiling - Supports --resolutions for multi-resolution runs in single process - All Wan 2.1/2.2 models, LoRA, MoE, configurable resolution/steps - all_wan_model_speed_metric.py: automated benchmark across all model variants - Streams output in real-time (tqdm visible) - Cleans up child processes on exit - BUILD.bazel targets for both scripts Signed-off-by: jglee-sqbits <jingu.lee@squeezebits.com>
# Conflicts: # max/kernels/src/nn/conv/conv.mojo
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.
Summary
This PR adds support for the Wan-Animate pipeline (
Wan-AI/Wan2.2-Animate-14B-Diffusers), a video generation model for motion transfer and character replacement built on top of the existing Wan I2V pipeline.clip_encoder.py,layers/) used as an image conditioning signal. The existing CLIP text encoder is extracted intoclip_modulev3to avoid a naming collision.WanTransformerModelwith pose injection (Conv3d), CLIP image cross-attention, a face adapter (WanAnimateFaceEncoder), and a motion encoder (WanAnimateMotionEncoder). Transformer layers are refactored into alayers/subpackage.WanAnimatePipelineextendingWanI2VPipeline, supporting animate mode (motion transfer) and replace mode (background-preserving character replacement via mask) with multi-segment processing and temporal overlap.PixelGenerationTokenizerand addsvideo_processor.pyto handle pose video, face pixels, background video, and mask inputs for the Animate pipeline.How to Run
The Wan-Animate pipeline requires preprocessed driving videos — a skeleton pose video (DWPose renders) and a cropped face video — rather than raw footage. To generate them from a raw driving video, use the official preprocessing scripts.
Alternatively, pre-processed sample assets are available for download at https://huggingface.co/datasets/squeezebits/diffusion-benchmark.
Animate Mode
./bazelw run //max/examples/diffusion:simple_offline_video_generation -- \ --model Wan-AI/Wan2.2-Animate-14B-Diffusers \ --input-image <character.jpeg> \ --pose-video <pose.mp4> \ --face-video <face.mp4> \ --prompt "A character moving naturally." \ --height 480 --width 848 --num-frames 77 \ --num-inference-steps 40 --seed 42 --num-warmups 1 \ --guidance-scale 1.0 \ --output output_animate.mp4Replace Mode
./bazelw run //max/examples/diffusion:simple_offline_video_generation -- \ --model Wan-AI/Wan2.2-Animate-14B-Diffusers \ --input-image <character.jpeg> \ --pose-video <pose.mp4> \ --face-video <face.mp4> \ --prompt "A character moving naturally." \ --height 480 --width 848 --num-frames 77 \ --num-inference-steps 40 --seed 42 --num-warmups 1 \ --guidance-scale 1.0 \ --output output_replace.mp4 --animate-mode replace \ --background-video <background.mp4> \ --mask-video <mask.mp4>Checklist
sequence of smaller PRs
./bazelw run formatto format my changesAssisted-by:trailer in my commit message or this PR description(see AI Tool Use Policy)
Assisted-by: Claude Code