from safetensors.torch import load_file, save_file import torch # --- Input and output file paths --- src = "hlpvWkBrqzopjecZbuVIA_pytorch_lora_weights.safetensors" dst = "hlpvWkBrqzopjecZbuVIA_pytorch_lora_weights_sdxl.safetensors" # --- Load original LoRA weights --- weights = load_file(src) new_weights = {} # --- Simple rename mapping for SDXL --- for k, v in weights.items(): k2 = k.replace("lora_unet_", "unet.") \ .replace("lora_te_", "text_encoder.") \ .replace("lora_te2_", "text_encoder_2.") new_weights[k2] = v.clone() # --- Save as SDXL-compatible LoRA --- save_file(new_weights, dst) print(f"✅ Converted and saved as {dst}")