Skip to content

Conversation

tolgacangoz
Copy link
Contributor

@tolgacangoz tolgacangoz commented Oct 6, 2025

This PR is fixing #12441.

Project Page: https://humanaigc.github.io/wan-animate/

TODOs:

  • WanAnimatePipeline
  • WanAnimateTransformer3DModel: Since diffusers doesn't like too many abstractions, I am removing and merging several small classes and functions, etc.
  • Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • Did you write any new necessary tests?
Comparison with the original repo
Try WanAnimatePipeline!

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

@tolgacangoz tolgacangoz changed the title Add Wan-Animate: Unified Character Animation and Replacement with Holistic Replication Add Wan2.2-Animate: Unified Character Animation and Replacement with Holistic Replication Oct 6, 2025
tolgacangoz and others added 24 commits October 7, 2025 11:14
- Introduced WanAnimateTransformer3DModel and WanAnimatePipeline.
- Updated get_transformer_config to handle the new model type.
- Modified convert_transformer to instantiate the correct transformer based on model type.
- Adjusted main execution logic to accommodate the new Animate model type.
…prove error handling for undefined parameters
…work for character animation and replacement

- Added Wan 2.2 Animate 14B model to the documentation.
- Introduced the Wan-Animate framework, detailing its capabilities for character animation and replacement.
- Included example usage for the WanAnimatePipeline with preprocessing steps and guidance on input requirements.
- Introduced `WanAnimateGGUFSingleFileTests` to validate functionality.
- Added dummy input generation for testing model behavior.
- Introduced `EncoderApp`, `Encoder`, `Direction`, `Synthesis`, and `Generator` classes for enhanced motion and appearance encoding.
- Added `FaceEncoder`, `FaceBlock`, and `FaceAdapter` classes to integrate facial motion processing.
- Updated `WanTimeTextImageMotionEmbedding` to utilize the new `Generator` for motion embedding.
- Enhanced `WanAnimateTransformer3DModel` with additional face adapter and pose patch embedding for improved model functionality.
- Introduced `pad_video` method to handle padding of video frames to a target length.
- Updated video processing logic to utilize the new padding method for `pose_video`, `face_video`, and conditionally for `background_video` and `mask_video`.
- Ensured compatibility with existing preprocessing steps for video inputs.
…roved video processing

- Added optional parameters: `conditioning_pixel_values`, `refer_pixel_values`, `refer_t_pixel_values`, `bg_pixel_values`, and `mask_pixel_values` to the `prepare_latents` method.
- Updated the logic in the denoising loop to accommodate the new parameters, enhancing the flexibility and functionality of the pipeline.
…eneration

- Updated the calculation of `num_latent_frames` and adjusted the shape of latent tensors to accommodate changes in frame processing.
- Enhanced the `get_i2v_mask` method for better mask generation, ensuring compatibility with new tensor shapes.
- Improved handling of pixel values and device management for better performance and clarity in the video processing pipeline.
…and mask generation

- Consolidated the handling of `pose_latents_no_ref` to improve clarity and efficiency in latent tensor calculations.
- Updated the `get_i2v_mask` method to accept batch size and adjusted tensor shapes accordingly for better compatibility.
- Enhanced the logic for mask pixel values in the replacement mode, ensuring consistent processing across different scenarios.
…nced processing

- Introduced custom QR decomposition and fused leaky ReLU functions for improved tensor operations.
- Implemented upsampling and downsampling functions with native support for better performance.
- Added new classes: `FusedLeakyReLU`, `Blur`, `ScaledLeakyReLU`, `EqualConv2d`, `EqualLinear`, and `RMSNorm` for advanced neural network layers.
- Refactored `EncoderApp`, `Generator`, and `FaceBlock` classes to integrate new functionalities and improve modularity.
- Updated attention mechanism to utilize `dispatch_attention_fn` for enhanced flexibility in processing.
@a-free-a
Copy link

Hello, thank you for your contribution! I'm very interested in this project and would like to ask how the progress is going so far. I'm also trying it out myself and would love to keep up with your progress.

@tolgacangoz
Copy link
Contributor Author

tolgacangoz commented Oct 13, 2025

Hi @a-free-a. This PR will be my top priority in 1/1.5/2 days. I estimate this PR will be completed in about 10 days (or less).

@a-free-a
Copy link

@tolgacangoz Wow, this is such exciting news — I’m really looking forward to it! I’m still a beginner and trying to get a better understanding of your work. Would you happen to have any tutorials or resources you could recommend to help me improve?

@tolgacangoz
Copy link
Contributor Author

tolgacangoz commented Oct 13, 2025

I think you can examine/study previously merged PRs, either about pipelines or any other kinds. This site seems really good in terms of theory and its implementations: https://nn.labml.ai. After studying, you could try to work on good first issue(Good for newcomers) and Good second issue-labeled issues.

@a-free-a
Copy link

@tolgacangoz Thanks a lot for the tips and the link! Really appreciate it. Hope everything goes great with your project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants