kohya-ss / sd-scripts

Apache License 2.0
5.15k stars 860 forks source link

Lora training on Playground V2 model #995

Open specblades opened 10 months ago

specblades commented 10 months ago

I got the error when trying to start lora train with Playground V2 model How to fix it? Looks like an error due model conversion, but I'm not sure.

https://huggingface.co/playgroundai/playground-v2-1024px-aesthetic Its sdxl but trained from scratch. Works in a1, comfy, fooocus without changin anything.

UPD Folk tells me that they (Playgorund) have modified TE a bit and that is why i got Unexpected key

Traceback (most recent call last):
  File "S:\kohya_ss-22.3.0\sdxl_train_network.py", line 185, in <module>
    trainer.train(args)
  File "S:\kohya_ss-22.3.0\train_network.py", line 228, in train
    model_version, text_encoder, vae, unet = self.load_target_model(args, weight_dtype, accelerator)
  File "S:\kohya_ss-22.3.0\sdxl_train_network.py", line 44, in load_target_model
    ) = sdxl_train_util.load_target_model(args, accelerator, sdxl_model_util.MODEL_VERSION_SDXL_BASE_V1_0, weight_dtype)
  File "S:\kohya_ss-22.3.0\library\sdxl_train_util.py", line 34, in load_target_model
    ) = _load_target_model(
  File "S:\kohya_ss-22.3.0\library\sdxl_train_util.py", line 75, in _load_target_model
    ) = sdxl_model_util.load_models_from_sdxl_checkpoint(model_version, name_or_path, device, model_dtype)
  File "S:\kohya_ss-22.3.0\library\sdxl_model_util.py", line 270, in load_models_from_sdxl_checkpoint
    info2 = _load_state_dict_on_device(text_model2, converted_sd, device=map_location)  # remain fp32
  File "S:\kohya_ss-22.3.0\library\sdxl_model_util.py", line 158, in _load_state_dict_on_device
    raise RuntimeError("Error(s) in loading state_dict for {}:\n\t{}".format(model.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for CLIPTextModelWithProjection:
        Unexpected key(s) in state_dict: "text_projection.weight.weight".
        Missing key(s) in state_dict: "text_projection.weight".
Traceback (most recent call last):
  File "C:\Users\blackbody\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\blackbody\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "S:\kohya_ss-22.3.0\venv\Scripts\accelerate.exe\__main__.py", line 7, in <module>
  File "S:\kohya_ss-22.3.0\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 47, in main
    args.func(args)
  File "S:\kohya_ss-22.3.0\venv\lib\site-packages\accelerate\commands\launch.py", line 986, in launch_command
    simple_launcher(args)
  File "S:\kohya_ss-22.3.0\venv\lib\site-packages\accelerate\commands\launch.py", line 628, in simple_launcher
    raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
kohya-ss commented 10 months ago

I've added a temporary workaround for this to dev branch. Please try it.

storuky commented 10 months ago

You can also train from original /playground-v2-1024px-aesthetic folder instead of safetensors file.

oracle9i88 commented 6 months ago

I've added a temporary workaround for this to dev branch. Please try it.我已为此向开发分支添加了一个临时解决方法。请尝试一下。

where is the dev branch