-
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
Convert diffusers
model weights to the original CompVis
ckpt format
#672
Comments
@patrickvonplaten, can I take this or is someone working on this? |
Hi @rashmimarganiatgithub , feel free to take this! Currently there is no one working on this as far as we are aware of! |
Please do :) a lot of folks want to do this due to dreambooth working better on diffusers but the various existing webuis don't use diffusers |
Upd2: ooops, I was tired and missed the initial comments, sorry Upd: Reference for another huggingface model .bin -> .ckpt converter |
That looks like it is for a tensorflow checkpoint, not pytorch? |
https://gist.github.com/jachiam/8a5c0b607e38fcc585168b90c686eb05 I think this works I got it to do a conversion on my machine and then generated a reasonable image with the converted weights |
I have now opened a PR to incorporate the conversion script into Diffusers |
Hey can you actually use this on your PC? |
Yes. |
Sorry my questions should have been: HOW do you use this on your own PC? I have downloaded a trained model from hugging face (plenty of folders inside) and I would like to convert that model into a ckpt file, how can I do this? Thanks |
Download the file, download pytorch and |
Thanks for all the contribution in this topic so far! I was able to convert my trained model to .ckpt using above script.
|
@MistApproach, would I be right in guessing you did textual inversion for your model, or something like that? It looks like you have one more text embedding than the stable-diffusion-webgui expects. I don't have a fix for this ready to go but if it's a persistent issue and you can walk me through how you made your model, I might understand it and be able to fix. |
@jachiam, you are absolutely right - i took SD vanilla model and trained new token using diffusers textual_inversion.py. While this works out of the box using StableDiffusionPipeline i now need to glue my model with front-end. Having no prior experience in ML i find the glueing process a bit overwhelming. EDIT: I did some more digging and apparently it is not stable-diffusion-webui being picky. The resulting .ckpt throws the very same error when trying txt2img.py script from official CompVis repo... |
@MistApproach the reason you're getting the size mismatch is because the textual inversion method simply adds one addition token to CLIP's text embedding layer. The default embedding matrix consists of 49408 text tokens for which the model learns an embedding (each embedding being a vector of 768 numbers). So to make sure the checkpoint works in the original CompVis repos, you'll need to update the size of the text encoder in the CompVis repository, something along the lines of Closing this issue as the request has been resolved. |
@NielsRogge, thanks for the explanation, appreciate it! Here's what i did with my trained model:
Then i have converted resulting diffusers model to checkpoint using @jachiam script. Unfortunately, both CompVis and stable-diffusion-webui still throw the very same error. |
@MistApproach , Hi, have you slove the problem now? |
@CrazyBoyM, unfortunately, no. Because of this i have dropped the idea of using stable-diffusion-webui for my frontend. Wrote a simple app using gradio and diffusers StableDiffusionPipeline under the hood. |
Can you please explain how to use that original ckpt > diffusors script? I don't understand the run syntax. |
Does the following issue maybe help in terms of what command should be run? |
I tested this and getting this error : #1877 |
There is a conversion script that converts the CompVis ckpt to diffusers available here, but the other way around does not exist yet.
As some Stable Diffusion UIs and utilities are built on top of the CompVis codebase, it would be useful to be able to use diffusers tools back on those. It would be great to have a community contribution on this!
The text was updated successfully, but these errors were encountered: