Skip to content

Commit beb932c

Browse files
[Conversion SD] Make sure weirdly sorted keys work as well (huggingface#1959)
1 parent 4401e6a commit beb932c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/convert_original_stable_diffusion_to_diffusers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False
443443
paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config
444444
)
445445

446-
if ["conv.weight", "conv.bias"] in output_block_list.values():
447-
index = list(output_block_list.values()).index(["conv.weight", "conv.bias"])
446+
output_block_list = {k: sorted(v) for k, v in output_block_list.items()}
447+
if ["conv.bias", "conv.weight"] in output_block_list.values():
448+
index = list(output_block_list.values()).index(["conv.bias", "conv.weight"])
448449
new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[
449450
f"output_blocks.{i}.{index}.conv.weight"
450451
]

0 commit comments

Comments
 (0)