Skip to content

Commit 9c757c2

Browse files
committed
fix SDXL block index to match LBW
1 parent b755ebd commit 9c757c2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

networks/svd_merge_lora.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,19 @@ def get_lbw_block_index(lora_name: str, is_sdxl: bool = False) -> int:
184184
elif "mid_block_" in lora_name:
185185
block_idx = 1 + NUM_OF_BLOCKS # 1-based index, num blocks, mid block
186186
else:
187+
# SDXL: some numbers are skipped
187188
if lora_name.startswith("lora_unet_"):
188189
name = lora_name[len("lora_unet_") :]
189190
if name.startswith("time_embed_") or name.startswith("label_emb_"): # 1, No LoRA in sd-scripts
190191
block_idx = 1
191192
elif name.startswith("input_blocks_"): # 1-8 to 2-9
192193
block_idx = 1 + int(name.split("_")[2])
193-
elif name.startswith("middle_block_"): # 10
194-
block_idx = 10
195-
elif name.startswith("output_blocks_"): # 0-8 to 11-19
196-
block_idx = 11 + int(name.split("_")[2])
197-
elif name.startswith("out_"): # 20, No LoRA in sd-scripts
198-
block_idx = 20
194+
elif name.startswith("middle_block_"): # 13
195+
block_idx = 13
196+
elif name.startswith("output_blocks_"): # 0-8 to 14-22
197+
block_idx = 14 + int(name.split("_")[2])
198+
elif name.startswith("out_"): # 23, No LoRA in sd-scripts
199+
block_idx = 23
199200

200201
return block_idx
201202

0 commit comments

Comments
 (0)