Skip to content
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

[Feature Request] Import custom yaml configurations #16

Open
iwr-redmond opened this issue Dec 7, 2024 · 0 comments
Open

[Feature Request] Import custom yaml configurations #16

iwr-redmond opened this issue Dec 7, 2024 · 0 comments

Comments

@iwr-redmond
Copy link

iwr-redmond commented Dec 7, 2024

Some SD15 (edit: and popular SDXL) checkpoints come with yaml configuration files that diffusers no longer supports.

If a yaml file exists with the same name as the checkpoint and/or is passed to Model_Diffusers by the user, it would be helpful to create a modern json configuration using the diffusers convert_from_ckpt pipeline.

My first thought was to copy the configuration conversion code out of this file, but having started to try this approach I feel it is needlessly complex and introduces room for error. Instead, I suggest that the workflow be as follows:

  1. Hash the file using the quick hashing code found in SD.Next's modules/hashes.py.
  2. Check each model folder in the diffusers cache for matching configuration files by searching for a custom file named legacy_hash.sha256, each of which (should it exist) will contain the matching file hash of the associated legacy checkpoint.
  3. If there is no existing configuration, run the conversion using the convert_from_ckpt.py pipeline.
  4. Save the hash into a 'legacy_hash.sha256' in the newly created diffusers cache folder, to allow future reference.
  5. Delete all .bin/.safetensors files in the cache for the newly converted model - perhaps unless the user passes a parameter to do otherwise.

In this way, when a checkpoint is loaded that has a yaml file with the same name (my_checkpoint.ckpt/.safetensors -> my_checkpoint.yaml) or is manually passed to Model_Diffusers, the conversion can be done automatically without too much of a performance penalty, as the model will need to be loaded into memory anyway. Optionally, the user could choose to keep the converted files and then refer to the diffusers-compatible version of the model in the future; however, if the user forgets this earlier conversion, the hashing function would prevent duplicated processing beyond the quick rehashing required to compare the legacy checkpoint with the diffusers cache.

A more efficient config-only solution may become available in the future if SD.Next issue 3350 is resolved.

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

No branches or pull requests

1 participant