I have created a customised model with kohya from the v1-5-pruned-emaonly.safetensors model and would now like to import this model into a c# application. I have read that I can use onnx to do this but I get stuck at loading the model weights. The code is as follows
from diffusers import StableDiffusionPipeline
import torch
from safetensors import safe_open
model_path = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
lora_path = "P718_long_crack_v1.safetensors"
pipe.unet.load_attn_procs(lora_path)
pipe.to("cuda")
unet = pipe.unet
producing the following error
Loading pipeline components...: 100%|██████████| 7/7 [00:01<00:00, 4.75it/s]
D:\ONNX\venv\lib\site-packages\diffusers\loaders\unet.py:212: FutureWarning: `load_attn_procs` is deprecated and will be removed in version 0.40.0. Using the `load_attn_procs()` method has been deprecated and will be removed in a future version. Please use `load_lora_adapter()`.
deprecate("load_attn_procs", "0.40.0", deprecation_message)
Traceback (most recent call last):
File "D:\ONNX\Converter.py", line 11, in <module>
pipe.unet.load_attn_procs(lora_path)
File "D:\ONNX\venv\lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "D:\ONNX\venv\lib\site-packages\diffusers\loaders\unet.py", line 217, in load_attn_procs
is_model_cpu_offload, is_sequential_cpu_offload = self._process_lora(
File "D:\ONNX\venv\lib\site-packages\diffusers\loaders\unet.py", line 333, in _process_lora
lora_config_kwargs = get_peft_kwargs(rank, network_alphas, state_dict, is_unet=True)
File "D:\ONNX\venv\lib\site-packages\diffusers\utils\peft_utils.py", line 153, in get_peft_kwargs
r = lora_alpha = list(rank_dict.values())[0]
IndexError: list index out of range
am i taking the wrong approach?