Skip to content

Conversation

@lzws
Copy link
Collaborator

@lzws lzws commented Oct 31, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lzws, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the 'Video-As-Prompt' (VAP) capability to the diffsynth library, specifically for the Wan2.1-14B model. This feature allows users to guide video generation by providing a reference video and associated textual prompts, offering more precise control over the content and style of the synthesized video. The changes encompass the definition of a new VAP-specific model, its seamless integration into the existing video generation pipeline, and an illustrative example to showcase its practical application.

Highlights

  • New Video-As-Prompt (VAP) Model: Introduced MotWanModel and related components (MotSelfAttention, MotWanAttentionBlock) to enable Video-As-Prompt functionality, allowing video generation to be guided by a reference video.
  • Pipeline Integration: Integrated the new VAP model into the WanVideoPipeline by adding a dedicated WanVideoUnit_VAP for processing VAP inputs, including prompt encoding, CLIP embedding, and latent preparation.
  • Model Configuration: Added a new model configuration entry for 'Video-As-Prompt-Wan2.1-14B' in model_config.py, specifying its components and parameters for loading.
  • Example Script: Provided a new example script (Wan2.1-VAP-14B.py) demonstrating how to perform inference using the Video-As-Prompt-Wan2.1-14B model with a reference video and prompts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Video-As-Prompt (VAP) with the Wan2.1-14B model. This includes a new MotWanModel for motion transfer, updates to the model configuration and wan_video_dit to handle the new model weights, and significant additions to the WanVideoPipeline to process VAP inputs. A new pipeline unit, WanVideoUnit_VAP, is added to handle the VAP logic, and an example script is provided to demonstrate its usage.

My review found a critical bug in the new pipeline unit that would cause a NameError, and a minor redundancy in the new model definition. Overall, the changes are well-structured for integrating this new feature.

if end_image is not None:
vap_end_image = pipe.preprocess_image(vap_video[-1].resize((width, height))).to(pipe.device)
if pipe.dit.has_image_pos_emb:
vap_clip_context = torch.concat([clip_context, pipe.image_encoder.encode_image([vap_end_image])], dim=1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The variable clip_context is used here but it has not been defined in this scope, which will lead to a NameError. It seems you intended to use vap_clip_context, which was defined on line 967.

Suggested change
vap_clip_context = torch.concat([clip_context, pipe.image_encoder.encode_image([vap_end_image])], dim=1)
vap_clip_context = torch.concat([vap_clip_context, pipe.image_encoder.encode_image([vap_end_image])], dim=1)

Comment on lines +267 to +270
if hash_state_dict_keys(state_dict) == '19debbdb7f4d5ba93b4ddb1cbe5788c7':
mot_layers = (0, 4, 8, 12, 16, 20, 24, 28, 32, 36)
else:
mot_layers = (0, 4, 8, 12, 16, 20, 24, 28, 32, 36)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if/else block is redundant because both branches assign the exact same tuple to mot_layers. You can simplify this to a single assignment.

        mot_layers = (0, 4, 8, 12, 16, 20, 24, 28, 32, 36)

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.

1 participant