-
Notifications
You must be signed in to change notification settings - Fork 869
Feat: Add AIGC model creation support to create_model #1431
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
Conversation
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.
Summary of Changes
Hello @Koko-ry, 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 introduces significant enhancements to the model creation process within the ModelScope Hub API, specifically by adding comprehensive support for AIGC (AI-Generated Content) models. I've extended the "create_model" function to accept AIGC-specific configurations, which now directs the creation request to a dedicated AIGC endpoint and automatically handles the upload of model files. A new utility class, "AigcModel", has been added to encapsulate and manage the various parameters and file processing required for AIGC model types like Checkpoints, LoRAs, and VAEs.
Highlights
- Enhanced Model Creation for AIGC: The "create_model" method in "modelscope/hub/api.py" has been updated to support the creation of AIGC models, accepting a new "aigc_config" parameter that specifies the model's type, base model, and file details.
- Dedicated AIGC Endpoint Integration: When an "aigc_config" is provided, the API call for model creation is now routed to a specific AIGC endpoint ("/api/v1/models/aigc"), ensuring proper categorization and handling of these specialized models.
- New "AigcModel" Utility: A new "AigcModel" class has been introduced in "modelscope/hub/utils/aigc.py". This class streamlines the management of AIGC model metadata, including defining "AigcType" (Checkpoint, LoRA, VAE) and "BaseModelType" (e.g., SD_1_5, SD_XL), and handles the processing of model file paths to extract necessary information like filename, SHA256 hash, and size.
- Automated Model File Upload: The "create_model" function now includes logic to automatically upload the AIGC model's associated files (either a single file or an entire directory) to the newly created repository, simplifying the workflow for users.
- Robust AIGC Parameter Validation: Assertions have been added to validate the "aigc_type" and "base_model_type" provided in the "aigc_config", ensuring that only valid AIGC model configurations are accepted.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
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 the capability to create AIGC models via the Hub API, adding an AigcModel
helper class for managing AIGC-specific parameters and file operations. The changes to HubApi.create_model
are well-organized to support this new functionality. My review highlights two main areas for improvement: replacing assert
statements with more robust validation to prevent them from being disabled in production, and standardizing logging by using the logging
module instead of print()
for better consistency and control. Additionally, there is a minor typo in the pull request title ('updata' should be 'update').
modelscope/hub/api.py
Outdated
@@ -61,6 +62,7 @@ | |||
raise_for_http_status, raise_on_error) | |||
from modelscope.hub.git import GitCommandWrapper | |||
from modelscope.hub.repository import Repository | |||
from modelscope.hub.utils.aigc import DEFAULT_AIGC_COVER_IMAGE, AigcModel |
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.
unused DEFAULT_AIGC_COVER_IMAGE
另外PR的名字命名有错误; PR的描述应写清楚增加/更新了哪些内容 |
modelscope/cli/create.py
Outdated
f'{self.args.from_json}') | ||
aigc_model = AigcModel.from_json_file(self.args.from_json) | ||
# model_id must still be provided if not in json, or for override | ||
model_id = self.args.repo_id or aigc_model.model_id |
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.
aigc_model.model_id 中的 model_id 不存在
No description provided.