Skquark / AI-Friends

A collection of handy helpers for AI art generation, AI writing and other experimental tools
49 stars 8 forks source link

Models from HuggingFace don't download #10

Open adamaxis opened 6 months ago

adamaxis commented 6 months ago

I add the HF_TOKEN key to colab and run colab w/ default settings. It loads the window. I add the huggingface key to the window. I keep everything at default settings and hit 'install' It grabs a handful of files in the notebook and then gets to loading pipline components, which never goes past 0 In the window, it says "Looks like you need to accept the HuggingFace SDXL-Base V1 Model Card to use Checkpoint Error, no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory /root/.cache/huggingface/hub/models-stabilityai--stable-diffusion-xl-base-1.0/snapshots/bunchofnumbers/text_encoder_2

There is no model card to accept on the huggingface page. I looked it up and apparently they removed this requirement.

Skquark commented 6 months ago

That's a new one for just loading the default SDXL-Base model, that's been installing reliably for a while, so something in the core must of broke. Investigating it and running tests, and one thing I noticed is Colab just updated to Torch 2.2.1 finally, and looking into that error has been linked with the version of Transformers. I made a few modifications to see if I can debug it, then ran a test with just installing SDXL Base, and it worked correctly. I'm trying to reproduce what you got but haven't been able to. That might mean that it's working fine now, so try again, submit error if it comes up again. Thanks, lemme know..

adamaxis commented 6 months ago

image

Still getting same error. I have my huggingface API key in the text box properly

Skquark commented 6 months ago

Alright, was messing with it all day and finally figured it out... It was initially working for me because I was using a Cache Dir that had a previous copy of SDXL-Base saved, which was working fine, but when I cleared my Cache directory I was able to reproduce the error. Did some tinkering and hunted down the cause, and looks like the updated version wanted to be loaded with use_safetensors=True even though it seemed like it had all the files to not need that. Anyways, patched things up and it looks good again. Thanks for helping me discover this one, would have taken me a while to realize it was broken if you didn't report it, and it was an important one.. Should be working for you now, I hope. Trying to find all those overlooked quirks remaining before publicizing this app too much, it's always changing and it's hard to test everything on my own. Thanks, please let me know if there's anything else..

adamaxis commented 6 months ago

What version of python should be installed locally for the windows version of this?

Skquark commented 6 months ago

Typically I've been running on 3.10, but was working on 3.8 & 3.9 before. I have not tried it with the latest 3.12 on my computer but I imaging it works the same without any breaks. Actually I take that back, I just read PyTorch doesn't run on 3.12, it's recommended to use 3.11.... The launcher bat file and py script takes care of all the other installs, tried to make it as easy as possible and the install worked on all the Windows computers I've tested on. Even runs well without a good GPU, I use it locally for the Prompt Helpers making the Prompts List off Colab, or to use the API based stuff like Stability API, Horde, Dall-e 3, etc. So did you get everything running well on Colab and confirm the SDXL model was working? Hope the other parts were running well and you're able to enjoy it. Lemme know.

adamaxis commented 6 months ago

The pipeline stuff loads now, but I'm still having issues. When I try to use image variation, it stops at 60% loading with the error Loading pipeline components...:  60%  3/5 [01:51<01:20, 40.38s/it] Exception in thread Thread-186 (): Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, *self._kwargs) File "/content/sdd_colab.py", line 6560, in ElevatedButton(content=Text("🖍️ Get Image Variation", size=20), color=colors.ON_PRIMARY_CONTAINER, bgcolor=colors.PRIMARY_CONTAINER, height=45, onclick=lambda : run_image_variation(page)), File "/content/sdd_colab.py", line 27359, in run_image_variation pipe_image_variation = StableDiffusionImageVariationPipeline.from_pretrained(model_id, safety_checker=None, cache_dir=prefs['cache_dir'] if bool(prefs['cache_dir']) else None) File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/pipeline_utils.py", line 819, in from_pretrained loaded_sub_model = load_sub_model( File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/pipeline_loading_utils.py", line 473, in load_sub_model loaded_sub_model = load_method(os.path.join(cached_folder, name), loading_kwargs) File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 3531, in from_pretrained ) = cls._load_pretrained_model( File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 3958, in _load_pretrained_model new_error_msgs, offload_index, state_dict_index = _load_state_dict_into_meta_model( File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 812, in _load_state_dict_into_meta_model set_module_tensor_to_device(model, param_name, param_device, **set_module_kwargs) File "/usr/local/lib/python3.10/dist-packages/accelerate/utils/modeling.py", line 348, in set_module_tensor_to_device raise ValueError( ValueError: Trying to set a tensor of shape torch.Size([768, 1024]) in "weight" (which has shape torch.Size([512, 1024])), this look incorrect.

Skquark commented 6 months ago

Good to hear. So the Image Variation was working when I set it up, but I haven't tested it for a while. Looks like they changed the HuggingFace model that we load for it to "lambdalabs/sd-image-variations-diffusers" revision v2.0 and I was using a different model that they updated. Thanks for pointing it out, I corrected it but I haven't tested it yet. Should work, everything else looks right in that, but lemme know. I'll make sure myself later too. Thanks for the bug report..

adamaxis commented 6 months ago

Ok cool. Yea I'm gonna mess around with things some more, if I notice something else broken I will let you know.

adamaxis commented 6 months ago

image Imagine variation ran without any visible errors on the notebook, but when it went to finally generate the image, I received this message Using sdxl-base v1 and stable diffusion v2.1 x512

adamaxis commented 6 months ago

I restarted the book completely and changed over to stable diffusion 1.5. Same error as above with image variation, also LEdits+ didn't seem to work either and gave this error image

Skquark commented 6 months ago

Good catches, thanks.. I just added LEdits++ this week and only tested with SDXL mode which worked, but in normal SD the invert didn't take the negative_prompt that SDXL pipeline did. That should be fixed now. For the Image Variation, I may have been resizing incorrectly, was doing it with an older method that was in the ImageVariation pipeline example, but now I'm noticing they changed the example. I made the updates there, but I still haven't gotten around to testing it yet to make sure. I appreciate you trying out the side features, most of the people that have been testing just use the basic stuff. I spend more time coding than using it myself.. Lemme know what ya catch next.

adamaxis commented 6 months ago

Encountered an issue while loading AnimeXL image

adamaxis commented 6 months ago

SDXL-Turbo also failed image

Skquark commented 6 months ago

Thanks, it's been kinda tricky to add new models when there's a few different types of compatibility, whether it has an fp16 variant, if it uses safetensors or not, etc.. I corrected the Anime-XL and SDXL-Turbo, should work now but haven't tested yet. I tested Image Variation after my fix and that's working well now. Working on the LEdits++ and I think I found the issue and corrected it, but not 100% sure. Getting there, but there's a lot of factors in the code I need to perfect. Thanks for your patience and bug reporting, appreciated.