Skip to content

Commit

Permalink
[Conversion SD] Make sure weirdly sorted keys work as well (huggingfa…
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickvonplaten authored Jan 10, 2023
1 parent 4401e6a commit beb932c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/convert_original_stable_diffusion_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False
paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config
)

if ["conv.weight", "conv.bias"] in output_block_list.values():
index = list(output_block_list.values()).index(["conv.weight", "conv.bias"])
output_block_list = {k: sorted(v) for k, v in output_block_list.items()}
if ["conv.bias", "conv.weight"] in output_block_list.values():
index = list(output_block_list.values()).index(["conv.bias", "conv.weight"])
new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[
f"output_blocks.{i}.{index}.conv.weight"
]
Expand Down

0 comments on commit beb932c

Please sign in to comment.