-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Checkpoint conversion script from Diffusers => Stable Diffusion (CompVis) #701
Conversation
The documentation is not available anymore as the PR was closed or merged. |
A few folks in the Stable Diffusion discord are also reporting that this works for them. |
Hm, also worth noting it only handles the Stable Diffusion v1-4 architecture, and would not be generally applicable to other architectures. |
The simplest test would be to do a side-by-side comparison of images from an unconverted CompVis model vs the same model converted to diffusers format and back again using your script, all using the same prompt and seed. They should generate identical images. |
Would we consider it acceptable if I just took a Diffusers model, converted to CompVis format, made an image with the CompVis format, converted back to Diffusers format, converted again to CompVis format, and made a comparison image in CompVis format? TBH I mostly did this to avoid having to download an original CompVis format checkpoint file, because an hour into the first 1.5 hour download the internet cut out and the download had to restart. (Yes, I spent ~8 hours coding a script to avoid a 1.5 hours download.) |
Should be fine imo. The goal is just to show the conversion is correct by showing it's reversible without affecting its output |
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.
Thanks a lot for the PR !From a quick look it looks good, will play around a bit and then we can merge.
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.
Cool looks good to me!
Thanks @jachiam ! |
…Vis) (huggingface#701) * Conversion script * ran black * ran isort * remove unused import * map location so everything gets loaded onto CPU before conversion * ran black again * Update setup.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Thank you so much for the work you've put into making this script, but unfortunately now the script no longer works because the weights under Please let us know when you may get around to updating this script so that it works with |
My utmost apologies; I did not see this commit which has updated this script so that it works with |
I added a script that converts from the Diffusers save format to the Stable Diffusion checkpoint format.
Some notes: it only handles the UNet, the VAE, and the Text Encoder. Nothing else. No optimization state is preserved.
I think it works. I'm not ten million percent sure. It works locally in that after a conversion, all of the keys for the new checkpoint's state_dict do indeed match a corresponding key in a Stable Diffusion model, I can load it, and an image generated using the SD checkpoint appears basically right. I have not tested this beyond generating two images.
This would solve Issue #672.
Looking for advice on what would constitute a stronger test here / make this a passable script.