Skip to content

feat: add Wan2.2 Animate 2 video models - #5309

Open
Minamiyama wants to merge 1 commit into
xorbitsai:mainfrom
Minamiyama:models/wan2_2-animate-2
Open

feat: add Wan2.2 Animate 2 video models#5309
Minamiyama wants to merge 1 commit into
xorbitsai:mainfrom
Minamiyama:models/wan2_2-animate-2

Conversation

@Minamiyama

Copy link
Copy Markdown
Collaborator

No description provided.

@XprobeBot XprobeBot added this to the v3.x milestone Aug 12, 2026

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

Copy link
Copy Markdown
Contributor

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 adds support for the Wan2.2-Animate-2-14B and Wan2.2-Animate-2-14B-Distilled character animation models (family WanAnimate2) by introducing a video parameter to the image_to_video endpoint across the RESTful API, async/sync clients, and diffusers model backend. Feedback highlights critical issues: both RESTful clients need to read the video file from disk when a local path string is provided rather than uploading the path string itself; in diffusers.py, fps must be popped from generate_kwargs to prevent a downstream TypeError crash, the temporary file path should be assigned before writing to ensure cleanup on failure, and local file paths should be validated for existence.

Comment thread xinference/client/restful/async_restful_client.py
Comment thread xinference/client/restful/restful_client.py
Comment on lines +335 to +344
fps = generate_kwargs.get("fps", 24)
temp_video_path = None
try:
if isinstance(video, bytes):
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as f:
f.write(video)
temp_video_path = f.name
video = temp_video_path
elif not isinstance(video, str):
raise TypeError("`video` must be video bytes or a local path")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

There are three issues in this block:

  1. fps is retrieved using get but not popped from generate_kwargs. Since fps is not a valid parameter for the underlying WanAnimate2Pipeline.__call__ method, leaving it in generate_kwargs will cause a TypeError crash.
  2. If f.write(video) fails, temp_video_path remains None, leaving an orphaned temporary file on disk. Setting temp_video_path before writing ensures it is cleaned up in the finally block.
  3. If video is a string path, we should check if the file exists to fail fast with a clear error.
            fps = generate_kwargs.pop("fps", 24)
            temp_video_path = None
            try:
                if isinstance(video, bytes):
                    with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as f:
                        temp_video_path = f.name
                        f.write(video)
                    video = temp_video_path
                elif isinstance(video, str):
                    if not os.path.exists(video):
                        raise FileNotFoundError(f"Driving video path does not exist: {video}")
                else:
                    raise TypeError("`video` must be video bytes or a local path")
References
  1. Avoid adding unused parameters to launch or configuration arguments if they are not directly consumed, as they can leak through **kwargs into downstream model construction. Instead, clean up stale or internal fields and overwrite only the required parameters.

@Minamiyama
Minamiyama force-pushed the models/wan2_2-animate-2 branch 2 times, most recently from 7fededb to e4d594e Compare August 12, 2026 05:55
@Minamiyama
Minamiyama force-pushed the models/wan2_2-animate-2 branch 2 times, most recently from d002764 to 1cdac88 Compare August 12, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants