-
Notifications
You must be signed in to change notification settings - Fork 87
feat(diffusers): add HunyuanImage21 to mindone.diffusers #1400
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: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Cui-yshoho, 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 expands the capabilities of the 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 adds support for the HunyuanImage2.1 model, including new pipelines, models, and documentation. A significant part of the changes involves a refactoring of the guider classes, which improves their API and consistency. The changes are extensive and well-structured. However, I've found a few critical issues, including incorrect API usage for MindSpore and a potential security vulnerability in the remote code trust logic. There are also some minor issues in the documentation that should be addressed for clarity.
| sliced_data = self.running_average[slice_indices] | ||
|
|
||
| # Format the slice for display (convert to float32 for numpy compatibility with bfloat16) | ||
| slice_str = str(sliced_data.detach().float().cpu().numpy()) |
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 line appears to be copied from a PyTorch implementation. The methods .detach(), .cpu(), and .numpy() are not available on MindSpore tensors and will cause a runtime error. Please use the MindSpore equivalents. For example, .asnumpy() should be used to convert a tensor to a NumPy array, and .to(ms.float32) to cast the dtype.
| slice_str = str(sliced_data.detach().float().cpu().numpy()) | |
| slice_str = str(sliced_data.to(ms.float32).asnumpy()) |
| if not has_remote_code and trust_remote_code: | ||
| raise ValueError( | ||
| "Selected model repository does not happear to have any custom code or does not have a valid `config.json` file." | ||
| ) |
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 logic for handling trust_remote_code appears to be incorrect. The condition if not has_remote_code and trust_remote_code: will fail to raise an error when has_remote_code is True and trust_remote_code is False. This is a security risk as it could allow untrusted remote code to be executed. The logic should be inverted to raise an error when remote code is present but not trusted.
| if not has_remote_code and trust_remote_code: | |
| raise ValueError( | |
| "Selected model repository does not happear to have any custom code or does not have a valid `config.json` file." | |
| ) | |
| if has_remote_code and not trust_remote_code: | |
| raise ValueError( | |
| f"Repo {pretrained_model_name_or_path} has custom code which must be trusted to be used. Please set `trust_remote_code=True`." | |
| ) |
| sliced_data = self.running_average[slice_indices] | ||
|
|
||
| # Format the slice for display (convert to float32 for numpy compatibility with bfloat16) | ||
| slice_str = str(sliced_data.float().numpy()) |
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 method .float() is a PyTorch API. The MindSpore equivalent is .to(ms.float32). Also, while .numpy() is an alias for .asnumpy(), using .asnumpy() is more idiomatic for MindSpore and less prone to confusion.
| slice_str = str(sliced_data.float().numpy()) | |
| slice_str = str(sliced_data.to(ms.float32).asnumpy()) |
|
|
||
| # AutoencoderKLHunyuanImage | ||
|
|
||
| The 2D variational autoencoder (VAE) model with KL loss used in [HunyuanImage2.1]. |
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 link for HunyuanImage2.1 is missing. It should point to the model's repository for user reference, similar to other documentation files in this PR.
| The 2D variational autoencoder (VAE) model with KL loss used in [HunyuanImage2.1]. | |
| The 2D variational autoencoder (VAE) model with KL loss used in [HunyuanImage2.1](https://github.com/Tencent-Hunyuan/HunyuanImage-2.1). |
|
|
||
| ## HunyuanImage-2.1-Distilled | ||
|
|
||
| use `distilled_guidance_scale` with the guidance-distilled checkpoint, |
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.
| distilled_guidance_scale=3.25, | ||
| height=2048, | ||
| width=2048, | ||
| generator=generator, |
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.
1ec8c2e to
e07aa90
Compare
e07aa90 to
bdbe81b
Compare
What does this PR do?
Fixes # (issue)
Adds # (feature)
Before submitting
What's New. Here are thedocumentation guidelines
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@xxx