-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix/wan animate frame alignment #1335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0c09523
9e636c8
48a6826
42c6903
1304e6f
91ae54f
d5b7ad7
99b1887
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,15 +37,15 @@ | |
|
|
||
| # Animate | ||
| input_image = Image.open("data/examples/wan/animate/animate_input_image.png") | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4").raw_data()[:81-4] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4").raw_data()[:81-4] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4").raw_data()[:77] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4").raw_data()[:77] | ||
| video = pipe( | ||
| prompt="视频中的人在做动作", | ||
| seed=0, tiled=True, | ||
| input_image=input_image, | ||
| animate_pose_video=animate_pose_video, | ||
| animate_face_video=animate_face_video, | ||
| num_frames=81, height=720, width=1280, | ||
| num_frames=77, height=720, width=1280, | ||
|
Comment on lines
+40
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The number num_frames_to_process = 77
animate_pose_video = VideoData(...).raw_data()[:num_frames_to_process]
animate_face_video = VideoData(...).raw_data()[:num_frames_to_process]
video = pipe(
...
num_frames=num_frames_to_process,
...
) |
||
| num_inference_steps=20, cfg_scale=1, | ||
| ) | ||
| save_video(video, "video_1_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
|
|
@@ -56,10 +56,10 @@ | |
| lora_state_dict = {i: lora_state_dict[i].to(torch.bfloat16) for i in lora_state_dict} | ||
| pipe.load_lora(pipe.dit, state_dict=lora_state_dict) | ||
| input_image = Image.open("data/examples/wan/animate/replace_input_image.png") | ||
| animate_pose_video = VideoData("data/examples/wan/animate/replace_pose_video.mp4").raw_data()[:81-4] | ||
| animate_face_video = VideoData("data/examples/wan/animate/replace_face_video.mp4").raw_data()[:81-4] | ||
| animate_inpaint_video = VideoData("data/examples/wan/animate/replace_inpaint_video.mp4").raw_data()[:81-4] | ||
| animate_mask_video = VideoData("data/examples/wan/animate/replace_mask_video.mp4").raw_data()[:81-4] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/replace_pose_video.mp4").raw_data()[:77] | ||
| animate_face_video = VideoData("data/examples/wan/animate/replace_face_video.mp4").raw_data()[:77] | ||
| animate_inpaint_video = VideoData("data/examples/wan/animate/replace_inpaint_video.mp4").raw_data()[:77] | ||
| animate_mask_video = VideoData("data/examples/wan/animate/replace_mask_video.mp4").raw_data()[:77] | ||
| video = pipe( | ||
| prompt="视频中的人在做动作", | ||
| seed=0, tiled=True, | ||
|
|
@@ -68,7 +68,8 @@ | |
| animate_face_video=animate_face_video, | ||
| animate_inpaint_video=animate_inpaint_video, | ||
| animate_mask_video=animate_mask_video, | ||
| num_frames=81, height=720, width=1280, | ||
| num_frames=77, height=720, width=1280, | ||
| num_inference_steps=20, cfg_scale=1, | ||
| ) | ||
| save_video(video, "video_2_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,16 @@ | |
| pipe.animate_adapter.load_state_dict(state_dict, strict=False) | ||
|
|
||
| input_image = VideoData("data/example_video_dataset/animate/animate_output.mp4", height=480, width=832)[0] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4", height=480, width=832).raw_data()[:81-4] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4", height=512, width=512).raw_data()[:81-4] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4", height=480, width=832).raw_data()[:77] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4", height=512, width=512).raw_data()[:77] | ||
| video = pipe( | ||
| prompt="视频中的人在做动作", | ||
| seed=0, tiled=True, | ||
| input_image=input_image, | ||
| animate_pose_video=animate_pose_video, | ||
| animate_face_video=animate_face_video, | ||
| num_frames=81, height=480, width=832, | ||
| num_frames=77, height=480, width=832, | ||
|
Comment on lines
+22
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The number num_frames_to_process = 77
animate_pose_video = VideoData(...).raw_data()[:num_frames_to_process]
animate_face_video = VideoData(...).raw_data()[:num_frames_to_process]
video = pipe(
...
num_frames=num_frames_to_process,
...
) |
||
| num_inference_steps=20, cfg_scale=1, | ||
| ) | ||
| save_video(video, "video_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
| save_video(video, "video_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,15 +18,16 @@ | |
| pipe.load_lora(pipe.dit, "models/train/Wan2.2-Animate-14B_lora/epoch-4.safetensors", alpha=1) | ||
|
|
||
| input_image = VideoData("data/example_video_dataset/animate/animate_output.mp4", height=480, width=832)[0] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4", height=480, width=832).raw_data()[:81-4] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4", height=512, width=512).raw_data()[:81-4] | ||
| animate_pose_video = VideoData("data/examples/wan/animate/animate_pose_video.mp4", height=480, width=832).raw_data()[:77] | ||
| animate_face_video = VideoData("data/examples/wan/animate/animate_face_video.mp4", height=512, width=512).raw_data()[:77] | ||
| video = pipe( | ||
| prompt="视频中的人在做动作", | ||
| seed=0, tiled=True, | ||
| input_image=input_image, | ||
| animate_pose_video=animate_pose_video, | ||
| animate_face_video=animate_face_video, | ||
| num_frames=81, height=480, width=832, | ||
| num_frames=77, height=480, width=832, | ||
|
Comment on lines
+21
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The number num_frames_to_process = 77
animate_pose_video = VideoData(...).raw_data()[:num_frames_to_process]
animate_face_video = VideoData(...).raw_data()[:num_frames_to_process]
video = pipe(
...
num_frames=num_frames_to_process,
...
) |
||
| num_inference_steps=20, cfg_scale=1, | ||
| ) | ||
| save_video(video, "video_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
| save_video(video, "video_Wan2.2-Animate-14B.mp4", fps=15, quality=5) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number
77is used in multiple places within this block. To improve readability and maintainability, it's good practice to define it as a variable before this block and reuse it. This avoids 'magic numbers' and makes it easier to change this value in the future. For example: