cloneofsimo / lora

Using Low-rank adaptation to quickly fine-tune diffusion models.
https://arxiv.org/abs/2106.09685
Apache License 2.0
6.94k stars 479 forks source link

CKPT: UnpicklingError: invalid load key, '-'. #163

Closed oscarnevarezleal closed 1 year ago

oscarnevarezleal commented 1 year ago

I trained a new model and then convert it to ckpt as described in #140

lora_add runwayml/stable-diffusion-v1-5 ./example_loras/lora_krk.safetensors ./dua.ckpt --alpha_1 0.7 --mode upl-ckpt-v2

Subsequently, when I tried to use it in automatic1111 I got this error the moment I try to load the model. I'm kind of lost here, not sure if is a problem with my automatic1111 instance or the generated file.

@cloneofsimo did you put your model into an specific folder?

Loading weights [c6c3b63cdc] from /content/stable-diffusion-webui/models/Stable-diffusion/dua.ckpt
changing setting sd_model_checkpoint to dua.ckpt: UnpicklingError
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/modules/shared.py", line 549, in set
    self.data_labels[key].onchange()
  File "/content/stable-diffusion-webui/modules/call_queue.py", line 15, in f
    res = func(*args, **kwargs)
  File "/content/stable-diffusion-webui/webui.py", line 120, in <lambda>
    shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights()))
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 450, in reload_model_weights
    state_dict = get_checkpoint_state_dict(checkpoint_info, timer)
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 228, in get_checkpoint_state_dict
    res = read_state_dict(checkpoint_info.filename)
  File "/content/stable-diffusion-webui/modules/sd_models.py", line 209, in read_state_dict
    pl_sd = torch.load(checkpoint_file, map_location=map_location or shared.weight_load_location)
  File "/content/stable-diffusion-webui/modules/safe.py", line 106, in load
    return load_with_extra(filename, extra_handler=global_extra_handler, *args, **kwargs)
  File "/content/stable-diffusion-webui/modules/safe.py", line 151, in load_with_extra
    return unsafe_torch_load(filename, *args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/serialization.py", line 795, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/opt/conda/lib/python3.10/site-packages/torch/serialization.py", line 1002, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '-'.
oscarnevarezleal commented 1 year ago

Nevermind, trained the model again and put both .pt and .ckpt into automatic1111 described paths and it worked /shrug