save_pretrained for serializing config. #11603
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Follow-up of #11539.
Test code:
Currently, it serializes the
config.json
. I think we agreed to manually save the block module that implements the custom block. It looks like so:diffusers-cli custom_blocks
can also do the work. More details:#11603 (comment)
More about the CLI stuff
Currently, for custom blocks, we need the block implementation module (say
block.py
), and theconfig.json
, and an optionalrequirements.txt
. @DN6 suggested a good idea over chat.We let the user implement
block.py
(or any other module name) inside a folder. We then provide a CLI tool (diffusers-cli init-block ...
) that would be run from the folder and spit out the following:So, the
config.json
will be created by the CLI command itself.There will be some reasonable defaults to serialize a desired
config.json
file but we will also expose certain CLI args to let the users take fine-grained control (would come in handy in case there are multiple block implementations and scripts).