Difficulty with testing trained models on HuggingFace

#4
by bryanbblewis11 - opened

I recently duplicated this space and upgraded to a GPU and was able to do several trainings. Upon completion, I have the delta.bin, but I'm not entirely certain how to use it. Ideally, I'd like to use this with Automatic1111. I attempted to convert the /results folder, which included what looks like a Diffusers structure, to a .ckpt, using the convert_diffusers_to_original_stable_diffusion.py script, which didn't load properly in Automatic1111 - specially reporting an error of;

size mismatch for cond_stage_model.model.token_embedding.weight: copying a param with shape torch.Size([49411, 1024]) from checkpoint, the shape in current model is torch.Size([49408, 1024])

Ideally, I'd like to use the "Test" tab in this HuggingFace space, but I run into errors regardless of which model I choose, which resolution I choose, or which prompt I put in (I notice that even if I use the "Test" tab on this main HuggingFace space, it throws an error, though the error can vary, whenever I try to test any of the default Custom Diffusion Weight Files).

Is there any guidance on how to use the "delta.bin" file with either Automatic1111 or here on HuggingFace?

Hi,
Thanks for the interest in our work. I am not sure what is the issue with the test tab as I am able to run inference without any issues on a A10G GPU. I have not tested it extensively on a T4 GPU but haven't had issues with batch-size 1.
Regarding using our models with "Automatic1111", I am currently traveling, but will release the code by next week to convert delta.bin files to the compatible checkpoints which can be used with "Automatic1111".
Will comment here once the code is released.

Thanks for your reply. I'm surprised you're not facing any issues with the test tab, as I've tried this on my own duplicated space, and your space, and they consistently throw errors (I do believe the training is working properly, though HuggingFace can tend to be a little buggy when the training completes, and it takes a few refreshes of the page before clicking the "Check Training Status" presents the option to download the delta.ckpt).

I do believe this worked properly at a point in time, but now my attempts to go directly to the "Test" tab, select a model, and choose a Custom Diffusion Weight File (whether that's one of my weight files or a sample one, like cat.bin), results in an error, usually along the lines of something like;

TypeError: new(): invalid data type 'str'

Thank you for your hard work on this project. I'm eager to be able to try this out in Automatic1111. I've been trying to adapt your code to work in a Google Colab, and made it pretty far, but ran into some issues with the bash script that I couldn't overcome, and paused.

I was able to run the inference today and found the issue. Some latest change in the github code broke the inference. I have corrected it now and should work.
Really sorry for the inconvenience.

Thanks a lot.

Thank you for your hard work on this! I duplicated the space again with all of the latest changes, and was able to test successfully. Super grateful for your help on this.

Very much looking forward to your guidance on how to use the delta.bin on Automatic1111. I do find HuggingFace to be pretty buggy, and being able to do the inference locally would be awesome!

Thank you again (feel free to close this issue as your recent work has resolved the issue).

Hi,
I have updated our repo to allow checkpoint conversion from diffuser to stable-diffusion-webui as explained here or by running the below commands.

python src/convert.py --delta_ckpt <path-to-folder>/delta.bin --ckpt <path-to-model-v1-4.ckpt> --mode diffuser-to-webui                  
# launch UI in stable-diffusion-webui directory
bash webui.sh --embeddings-dir <path-to-folder>/webui/embeddings  --ckpt <path-to-folder>/webui/model.ckpt

Currently the code only supports the stable-diffusion-v1-4 model. Also stable-diffusion-webui doesn't support loading embedding dynamically in the UI, thus it requires launching the UI with a specific model.
Let me know if you face any issues. Thanks.

@nupurkmr9 is it a joke?

can't convert: ModuleNotFoundError: No module named 'ldm'

When i install ldm, it gives me error since it's for Python 2.

user@435813d343a3:~/app/custom-diffusion/src$ python convert.py --delta_ckpt /home/user/app/results/delta.bin --ckpt model.ckpt --mode diffuser-to-webui
Traceback (most recent call last):
  File "convert.py", line 7, in <module>
    from ldm.util import instantiate_from_config
  File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/ldm.py", line 20
    print self.face_rec_model_path
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self.face_rec_model_path)?

Sign up or log in to comment