Linaqruf / kohya-trainer

Adapted from https://note.com/kohya_ss/n/nbf7ce8d80f29 for easier cloning
Apache License 2.0
1.85k stars 308 forks source link

Error running the Finetuner Lora model in WebUI #80

Closed younyokel closed 1 year ago

younyokel commented 1 year ago

Lora Finetuner I saved it with float precision and it seem to work in Colab but not in Automatic1111 WebUI. Here's the error:

activating extra network lora with arguments [<modules.extra_networks.ExtraNetworkParams object at 0x0000026E1B7C6B60>]: RuntimeError
Traceback (most recent call last):
  File "D:\Program Files\stable-diffusion-webui\modules\extra_networks.py", line 75, in activate
    extra_network.activate(p, extra_network_args)
  File "D:\Program Files\stable-diffusion-webui\extensions-builtin\Lora\extra_networks_lora.py", line 23, in activate
    lora.load_loras(names, multipliers)
  File "D:\Program Files\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 151, in load_loras
    lora = load_lora(name, lora_on_disk.filename)
  File "D:\Program Files\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 113, in load_lora
    module.weight.copy_(weight)
RuntimeError: output with shape [128, 320] doesn't match the broadcast shape [128, 320, 128, 320]

Hyperparameter:

+-------------------------------+------------------------------------------------------------------+
| Hyperparameter                | Value                                                            |
+-------------------------------+------------------------------------------------------------------+
| v2                            | True                                                             |
| v_parameterization            | True                                                             |
| network_dim                   | 128                                                              |
| network_alpha                 | 128                                                              |
| network_module                | networks.lora                                                    |
| network_weights               | False                                                            |
| network_train_on              | both                                                             |
| learning_rate                 | 0.0001                                                           |
| unet_lr                       | 0.0001                                                           |
| text_encoder_lr               | 5e-05                                                            |
| no_metadata                   | False                                                            |
| training_comment              | this_comment_will_be_stored_in_the_metadata                      |
| lr_scheduler                  | linear                                                           |
| lr_scheduler_num_cycles       | 1                                                                |
| lr_scheduler_power            | 1                                                                |
| pretrained_model_name_or_path | /content/pre_trained_model/illuminati_diffusion_v1.0.safetensors |
| vae                           | False                                                            |
| train_data_dir                | /content/fine_tune/train_data                                    |
| in_json                       | /content/fine_tune/meta_lat.json                                 |
| output_dir                    | /content/drive/MyDrive/fine_tune/output                          |
| keep_tokens                   | 2                                                                |
| resume_path                   | False                                                            |
| project_name                  | necromorph                                                       |
| mixed_precision               | fp16                                                             |
| save_precision                | float                                                            |
| save_n_epochs_type            | save_n_epoch_ratio                                               |
| save_n_epochs_type_value      | 1                                                                |
| save_model_as                 | safetensors                                                      |
| resolution                    | 768                                                              |
| train_batch_size              | 1                                                                |
| max_token_length              | 225                                                              |
| use_8bit_adam                 | False                                                            |
| dataset_repeats               | 10                                                               |
| num_epochs                    | 5                                                                |
| seed                          | 0                                                                |
| gradient_checkpointing        | True                                                             |
| gradient_accumulation_steps   | 1                                                                |
| clip_skip                     | 1                                                                |
| logging_dir                   | /content/fine_tune/logs                                          |
| log_prefix                    | necromorph                                                       |
| additional_argument           | --shuffle_caption --xformers                                     |
+-------------------------------+------------------------------------------------------------------+

Anyone know what's the problem?

Linaqruf commented 1 year ago

Apparently LoRA based on SDV2 model is broken in webui, you need to load it from kohya extension https://github.com/kohya-ss/sd-webui-additional-networks

younyokel commented 1 year ago

Thanks, it worked! But it's weird, cuz I only recently trained two other SD 2.1 models and they worked without this extension.

Linaqruf commented 1 year ago

Good to hear that!

Is it LoRA? of Full model? You can load SDV2 model in webui but not LoRA