-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Batch size #1205
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?
Batch size #1205
Conversation
Summary of ChangesHello @ahmeddawy, 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 enhances the training and evaluation infrastructure by introducing robust support for batch processing across the diffusion model pipeline. It refactors data loading and preprocessing to natively handle Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 support for batched training and validation, which is a significant enhancement. The changes are extensive, touching data preprocessing, argument parsing, the training runner, and model implementations to handle batched tensors. The addition of a validation loop with periodic evaluation is a great feature for monitoring model performance during training.
I've found a critical issue in the new batch collation logic that would prevent batched training from working correctly with custom dataset objects. I've also included a suggestion to improve the efficiency and readability of a new test script.
Overall, this is a great contribution. Addressing the identified issues will make the new batching functionality robust.
| if key in single_frame_keys: | ||
| frames = [] | ||
| for value in values: | ||
| if isinstance(value, list): |
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 check isinstance(value, list) is too restrictive. It will likely fail for custom sequence-like objects such as VideoData returned by the dataset, causing an error during batch collation. To make this more robust, you should check for the general Sequence type from collections.abc and explicitly exclude strings.
You'll need to add from collections.abc import Sequence at the top of the file.
| if isinstance(value, list): | |
| if isinstance(value, Sequence) and not isinstance(value, str): |
| else: | ||
| tensors = [] | ||
| for value in values: | ||
| if isinstance(value, list): |
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.
Similar to the previous comment, this isinstance(value, list) check is too restrictive and will fail for custom sequence types like VideoData. Using collections.abc.Sequence will make the collate function more general and prevent errors with different dataset implementations.
| if isinstance(value, list): | |
| if isinstance(value, Sequence) and not isinstance(value, str): |
| video = VideoData(str(video_path), height=480, width=832) | ||
| if len(video) >= 81 : | ||
| video = [video[i] for i in range(81)] | ||
| else: | ||
| video = [video[i] for i in range(len(video))] | ||
| reference_image = VideoData(str(video_path), height=480, width=832)[0] | ||
| vace_mask = VideoData(str(mask_path), height=480, width=832) | ||
| vace_mask = [vace_mask[i] for i in range(len(video))] |
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.
This block of code for loading and preparing the video, reference image, and mask can be made more efficient and readable.
- The
if/elseblock to truncate the video is verbose. Slicing ([:81]) is more Pythonic. reference_imageis created by reloading the same video file, which is inefficient. It can be retrieved from theVideoDataobject that's already loaded.- The list comprehension to create the mask can also be simplified using slicing.
The suggested change refactors this logic to be more concise and avoid redundant file I/O.
| video = VideoData(str(video_path), height=480, width=832) | |
| if len(video) >= 81 : | |
| video = [video[i] for i in range(81)] | |
| else: | |
| video = [video[i] for i in range(len(video))] | |
| reference_image = VideoData(str(video_path), height=480, width=832)[0] | |
| vace_mask = VideoData(str(mask_path), height=480, width=832) | |
| vace_mask = [vace_mask[i] for i in range(len(video))] | |
| video_data = VideoData(str(video_path), height=480, width=832) | |
| video = list(video_data[:81]) | |
| reference_image = video_data[0] | |
| vace_mask_data = VideoData(str(mask_path), height=480, width=832) | |
| vace_mask = list(vace_mask_data[:len(video)]) |
No description provided.