Skip to content
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

merged checkpoint works but lora weights does not work with kohya-ss sd-webui-additional-networks #1020

Closed
harrywang opened this issue Mar 5, 2023 · 8 comments
Labels
new Just added, you should probably sort this.

Comments

@harrywang
Copy link

harrywang commented Mar 5, 2023

I trained a model - training completed successfully. The merged model works (shows beckham):
Screenshot 2023-03-05 at 8 33 25 AM

however, when I use the generated Lora weights using https://github.com/kohya-ss/sd-webui-additional-networks, it has no effect:
Screenshot 2023-03-05 at 8 34 03 AM

I used another Lora weights I got from Civitai.com and it works - to confirm the extension is working.

The files are:

Screenshot 2023-03-05 at 9 01 07 AM

I found the following error in the log:

Loading weights [1a189f0be6] from /home/hjwang/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned.safetensors
Creating model from config: /home/hjwang/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying xformers cross attention optimization.
Model loaded in 1.2s (create model: 0.4s, apply weights to model: 0.3s, apply half(): 0.2s, move model to device: 0.3s).
activating extra network lora with arguments [<modules.extra_networks.ExtraNetworkParams object at 0x7ff3fc4817f0>]: TypeError
Traceback (most recent call last):
  File "/home/hjwang/stable-diffusion-webui/modules/extra_networks.py", line 75, in activate
    extra_network.activate(p, extra_network_args)
  File "/home/hjwang/stable-diffusion-webui/extensions-builtin/Lora/extra_networks_lora.py", line 23, in activate
    lora.load_loras(names, multipliers)
  File "/home/hjwang/stable-diffusion-webui/extensions-builtin/Lora/lora.py", line 151, in load_loras
    lora = load_lora(name, lora_on_disk.filename)
  File "/home/hjwang/stable-diffusion-webui/extensions-builtin/Lora/lora.py", line 83, in load_lora
    sd = sd_models.read_state_dict(filename)
  File "/home/hjwang/stable-diffusion-webui/modules/sd_models.py", line 224, in read_state_dict
    sd = get_state_dict_from_checkpoint(pl_sd)
  File "/home/hjwang/stable-diffusion-webui/modules/sd_models.py", line 197, in get_state_dict_from_checkpoint
    pl_sd = pl_sd.pop("state_dict", pl_sd)
TypeError: pop expected at most 1 argument, got 2

I guess this is the cause but don't know why - Can anyone help? What did I miss?

BTW, I found the following two closed related issues:

#695
#723

@harrywang harrywang added the new Just added, you should probably sort this. label Mar 5, 2023
@harrywang harrywang changed the title merged checkpoint works but lora weights does not work with merged checkpoint works but lora weights does not work with kohya-ss sd-webui-additional-networks Mar 5, 2023
@gammagoat
Copy link
Collaborator

The additional networks feature in a1111 was written by for kohya_ss model format. The main of this model uses the cloneofsimo implementation for LoRA and is not compatible. There is an option in dev to also have additional networks Loras for the non-extended version if you want to give it a try

@ArrowM
Copy link
Collaborator

ArrowM commented Mar 5, 2023

Also that non-extended version should get merged to main sometime today or tomorrow

@ArrowM ArrowM closed this as completed Mar 5, 2023
@harrywang
Copy link
Author

The additional networks feature in a1111 was written by for kohya_ss model format. The main of this model uses the cloneofsimo implementation for LoRA and is not compatible. There is an option in dev to also have additional networks Loras for the non-extended version if you want to give it a try

Thanks!

@harrywang
Copy link
Author

@gammagoat @ArrowM I see a PR merge #1014 did this merge "additional networks Loras for the non-extended version"? how to use/enable this? Any pointer? Thanks a lot!

@harrywang
Copy link
Author

I pulled from dev and don't know which saving option will make lora compatible with https://github.com/kohya-ss/sd-webui-additional-networks
Screenshot 2023-03-06 at 10 01 45 AM

@gammagoat
Copy link
Collaborator

Generate Lora weights for extra networks will save a file in the model/lora directory that will work (as long as you don't use extended Lora). I recommend deleting or moving all the old incompatible .pt files out of there.

@harrywang
Copy link
Author

Generate Lora weights for extra networks will save a file in the model/lora directory that will work (as long as you don't use extended Lora). I recommend deleting or moving all the old incompatible .pt files out of there.

awesome - will try and report back! Thanks!!

@harrywang
Copy link
Author

@gammagoat I trained again and the new lora weights work perfectly!! Thanks!
Screenshot 2023-03-06 at 10 52 48 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new Just added, you should probably sort this.
Projects
None yet
Development

No branches or pull requests

3 participants