File size: 673 Bytes
032314e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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}")