-
Notifications
You must be signed in to change notification settings - Fork 14
Description
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:
- Hash the file using the quick hashing code found in SD.Next's modules/hashes.py.
- 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.
- If there is no existing configuration, run the conversion using the convert_from_ckpt.py pipeline.
- Save the hash into a 'legacy_hash.sha256' in the newly created diffusers cache folder, to allow future reference.
- 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.