bmaltais / kohya_ss

Apache License 2.0
9.54k stars 1.23k forks source link

Unable to use Koyha LoCon trained model on automatic1111 #473

Closed joneschunghk closed 8 months ago

joneschunghk commented 1 year ago

I trained a LoRA with LoRA type "Koyha LoCon". And put the trained LoRA into "..\stable-diffusion-webui\extensions\sd-webui-additional-networks\models\lora". I have installed the extension "a1111-sd-webui-locon". But get the following error while generate.

LoRA weight_unet: 1, weight_tenc: 1, model: test_locon(41f996f7f517)
dimension: 16, alpha: 8.0, multiplier_unet: 1, multiplier_tenc: 1
create LoRA for Text Encoder: 72 modules.
create LoRA for U-Net: 192 modules.
original forward/weights is backed up.
Error running process_batch: D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py
Traceback (most recent call last):
  File "D:\My Documents\Python Projects\stable-diffusion-webui\modules\scripts.py", line 435, in process_batch
    script.process_batch(p, *script_args, **kwargs)
  File "D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py", line 209, in process_batch
    network, info = lora_compvis.create_network_and_apply_compvis(du_state_dict, weight_tenc, weight_unet, text_encoder, unet)
  File "D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\lora_compvis.py", line 102, in create_network_and_apply_compvis
    state_dict = network.apply_lora_modules(du_state_dict)              # some weights are applied to text encoder
  File "D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\lora_compvis.py", line 289, in apply_lora_modules
    state_dict = LoRANetworkCompvis.convert_state_dict_name_to_compvis(self.v2, du_state_dict)
  File "D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\lora_compvis.py", line 193, in convert_state_dict_name_to_compvis
    compvis_name = LoRANetworkCompvis.convert_diffusers_name_to_compvis(v2, tokens[0])
  File "D:\My Documents\Python Projects\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\lora_compvis.py", line 182, in convert_diffusers_name_to_compvis
    assert cv_name is not None, f"conversion failed: {du_name}. the model may not be trained by `sd-scripts`."
AssertionError: conversion failed: lora_unet_down_blocks_0_downsamplers_0_conv. the model may not be trained by `sd-scripts`.
bmaltais commented 1 year ago

Have you installed kohya_ss additional_network extension and tried to use that to access the LoCON?

joneschunghk commented 1 year ago

Have you installed kohya_ss additional_network extension and tried to use that to access the LoCON?

Yes, I have installed both "a1111-sd-webui-locon" and "sd-webui-additional-networks" extensions, and use additional network to access my LoRA and LoCon. It's perfect to generate images with LoRA. chrome-capture-2023-2-29

As I check starting logs, I found an error(?) message:

Additional Network extension not installed, Only hijack built-in lora
LoCon Extension hijack built-in lora successfully
[AddNet] Updating model hashes...
100%|███████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 22031.80it/s]
[AddNet] Updating model hashes...
100%|███████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 23819.99it/s]
bmaltais commented 1 year ago

Hummm... I suggest to open an issue with kohya directly as at this point it is related to the additional network extension: https://github.com/kohya-ss/sd-scripts