Skip to content

Conversation

@helloyongyang
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @helloyongyang, 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 refactors the way input parameters are handled throughout the system, moving from a direct initialization method to a more flexible two-step process involving empty object initialization followed by data population. This change enhances the modularity and extensibility of input configuration, introduces a new resize_mode option for image processing, and standardizes how aspect ratios and target shapes are managed across different inference runners. The refactoring also contributes to a cleaner codebase by removing an external dependency.

Highlights

  • Input Information Refactoring: The monolithic set_input_info function has been replaced by a more modular approach using init_empty_input_info to create an empty input object and update_input_info_from_dict or update_input_info_from_object to populate it from various sources.
  • New resize_mode Field: A resize_mode field has been added to all *InputInfo dataclasses (T2VInputInfo, I2VInputInfo, Flf2vInputInfo, VaceInputInfo, S2VInputInfo, AnimateInputInfo, T2IInputInfo, I2IInputInfo) to allow for more flexible image resizing strategies.
  • Enhanced Aspect Ratio and Shape Handling: The logic for determining custom shapes and aspect ratios in image runners (qwen_image_runner.py, z_image_runner.py) has been standardized and improved, including dynamic scaling for custom sizes and better integration with default aspect ratio maps.
  • Dependency Reduction: The EasyDict dependency has been removed from lightx2v/server/services/inference/worker.py, streamlining the input data processing.

🧠 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 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

The pull request introduces a significant refactoring of how input information is handled across various modules. The previous set_input_info function has been replaced by a more modular approach using init_empty_input_info for object creation and update_input_info_from_dict or update_input_info_from_object for populating data. This change enhances modularity and maintainability. Additionally, a resize_mode field has been added to all InputInfo dataclasses, and the default aspect_ratio in infer.py has been made empty, indicating more flexible handling of image dimensions. The ASPECT_RATIO_MAP constant was removed from z_image_runner.py, and the logic for determining custom shapes was centralized and enhanced in both qwen_image_runner.py and z_image_runner.py to include default aspect ratios and size constraints.

parser.add_argument("--return_result_tensor", action="store_true", help="Whether to return result tensor. (Useful for comfyui)")
parser.add_argument("--target_shape", nargs="+", default=[], help="Set return video or image shape")
parser.add_argument("--aspect_ratio", type=str, default="16:9")
parser.add_argument("--aspect_ratio", type=str, default="")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Changing the default aspect_ratio from "16:9" to an empty string "" could lead to unexpected behavior in parts of the system that rely on a non-empty default. If no aspect_ratio is explicitly provided, an empty string might not be a valid or expected value for downstream processing, potentially causing errors or incorrect aspect ratio calculations. It's generally safer to maintain a valid default or ensure explicit handling of the empty string.

width, height = int(width * scale), int(height * scale)
logger.warning(f"Custom shape is too large, scaled to {width}x{height}")
width, height = max(width, min_size), max(height, min_size)
logger.info(f"Qwen Image Runner got custom shape: {width}x{height}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logger.info message on this line incorrectly refers to "Qwen Image Runner". This appears to be a copy-paste error and should be corrected to "Z Image Runner" for accuracy and clarity in the logs.

Suggested change
logger.info(f"Qwen Image Runner got custom shape: {width}x{height}")
logger.info(f"Z Image Runner got custom shape: {width}x{height}")


aspect_ratio = self.input_info.aspect_ratio if self.input_info.aspect_ratio else self.config.get("aspect_ratio", None)
if aspect_ratio in as_maps:
logger.info(f"Qwen Image Runner got aspect ratio: {aspect_ratio}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logger.info message on this line incorrectly refers to "Qwen Image Runner". This appears to be a copy-paste error and should be corrected to "Z Image Runner" for accuracy and clarity in the logs.

Suggested change
logger.info(f"Qwen Image Runner got aspect ratio: {aspect_ratio}")
logger.info(f"Z Image Runner got aspect ratio: {aspect_ratio}")


config = set_config(self)
print_config(config)
print(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Replacing the dedicated print_config(config) function with a generic print(config) removes the structured logging and filtering capabilities provided by print_config (e.g., handling parallel configurations and removing device_mesh). This can lead to less informative or potentially verbose logging, and might expose internal configuration details that were previously suppressed.

Suggested change
print(config)
print_config(config)

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.

2 participants