-
Notifications
You must be signed in to change notification settings - Fork 178
[Feature]Add video-to-video (V2V) pipeline #829
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?
Conversation
control model support for Wan2.1
Summary of ChangesHello @Gary-ChenJL, 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 significantly extends the fastvideo library by introducing a comprehensive video-to-video (V2V) generation pipeline. It specifically adds support for the Wan2.1 control model, allowing users to generate new videos conditioned on an existing input video. The changes encompass new configuration classes for the specialized CLIP encoder, a dedicated stage for encoding video inputs into latent space, and robust handling of video file loading and preprocessing, alongside an illustrative example script. Highlights
Using Gemini Code AssistThe 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
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 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
|
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.
Code Review
This pull request introduces a video-to-video (V2V) pipeline for the Wan2.1 control model. The changes include new pipeline configurations, stages for handling video inputs, and updates to support the V2V workflow. My review focuses on correctness, maintainability, and potential bugs. I've identified several critical issues, including a resource leak from un-deleted temporary files, typos that will lead to ImportError
and AttributeError
, and a confusing typo in a configuration parameter (is_casual
vs is_causal
). I've also suggested improvements for code clarity, style, and efficiency, such as simplifying a complex preprocessing function and improving type hints.
pil_images = [] | ||
original_fps = None | ||
|
||
try: | ||
if video_path.endswith(".gif"): | ||
gif = PIL.Image.open(video_path) | ||
try: | ||
# GIF FPS estimation | ||
if hasattr(gif, 'info') and 'duration' in gif.info: | ||
duration_ms = gif.info['duration'] | ||
if duration_ms > 0: | ||
original_fps = 1000.0 / duration_ms | ||
|
||
while True: | ||
pil_images.append(gif.copy()) | ||
gif.seek(gif.tell() + 1) | ||
except EOFError: | ||
pass | ||
else: | ||
try: | ||
imageio.plugins.ffmpeg.get_exe() | ||
except AttributeError: | ||
raise AttributeError( | ||
"`Unable to find an ffmpeg installation on your machine. Please install via `pip install imageio-ffmpeg" | ||
) from None | ||
|
||
with imageio.get_reader(video_path) as reader: | ||
try: | ||
original_fps = reader.get_meta_data().get('fps', None) | ||
except: | ||
# Fallback: try to get from format-specific metadata | ||
try: | ||
original_fps = reader.get_meta_data().get('source_size', {}).get('fps', None) | ||
except: | ||
pass | ||
|
||
for frame in reader: | ||
pil_images.append(PIL.Image.fromarray(frame)) | ||
finally: | ||
# Clean up temporary file if it was created | ||
if was_tempfile_created and os.path.exists(video_path): | ||
os.remove(video_path) |
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.
I know the original code was not the best, but could you clean this up and remove all of these try except blocks?
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.
refactored
fastvideo/models/vision_utils.py
Outdated
pil_images = convert_method(pil_images) | ||
|
||
return pil_images | ||
return pil_images, original_fps |
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.
There's a few other places using this util method. We should either update those places or use a flag to return fps
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.
refactored, now backward compatible
Adds support for Wan2.1 control model