haofanwang / Lora-for-Diffusers

The most easy-to-understand tutorial for using LoRA (Low-Rank Adaptation) within diffusers framework for AI Generation Researchers🔥
MIT License
739 stars 46 forks source link

Error when running convert_original_stable_diffusion_to_diffusers #8

Open kopyl opened 1 year ago

kopyl commented 1 year ago

I run !python ./scripts/convert_original_stable_diffusion_to_diffusers.py --checkpoint_path /content/drive/MyDrive/sd/stable-diffusion-webui/models/Lora/100img_1-5.safetensors --dump_path /content/drive/MyDrive/Stable_diffusion/stable_diffusion_lora_weights/lora-only-100img_1-5 --from_safetensors

And get this error:

/usr/local/lib/python3.9/dist-packages/flax/core/frozen_dict.py:169: FutureWarning: jax.tree_util.register_keypaths is deprecated, and will be removed in a future release. Please use `register_pytree_with_keys()` instead.
  jax.tree_util.register_keypaths(
The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.
0it [00:00, ?it/s]
2023-03-26 13:58:12.913301: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64
2023-03-26 13:58:12.913397: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64
2023-03-26 13:58:12.913418: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
global_step key not found in model
Traceback (most recent call last):
  File "/content/diffusers/./scripts/convert_original_stable_diffusion_to_diffusers.py", line 128, in <module>
    pipe = download_from_original_stable_diffusion_ckpt(
  File "/usr/local/lib/python3.9/dist-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1157, in download_from_original_stable_diffusion_ckpt
    converted_unet_checkpoint = convert_ldm_unet_checkpoint(
  File "/usr/local/lib/python3.9/dist-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 379, in convert_ldm_unet_checkpoint
    new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"]
KeyError: 'time_embed.0.weight'

Last time it was some other error...

haofanwang commented 1 year ago

@kopyl What's your 100img_1-5.safetensors? Is it a normal sd model? It seems that diffusers cannot support it not.

kopyl commented 1 year ago

@haofanwang it's a LoRA created in kohya_ss GUI (around 10MB)

pgainullin commented 1 year ago

Ok so for me this was just a misunderstanding of what the script does - you actually need a Checkpoint file (typically 2gb+) and not a LoRA (which can be as small as 30Mb).

Alternatively, this is a possibly relevant convo here: https://github.com/godly-devotion/MochiDiffusion/issues/261