Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions stable_diffusion/stable_diffusion/model_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ def map_vae_weights(key, value):
if "to_v" in key:
key = key.replace("to_v", "value_proj")


# Map attention layers in SD-2-1-base:VAE
if "key" in key:
key = key.replace("key", "to_k")
if "proj_attn" in key:
key = key.replace("proj_attn", "out_proj")
if "query" in key:
key = key.replace("query", "query_proj")
if "value" in key:
key = key.replace("value", "value_proj")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't look correct given that they will result in value_proj_proj and query_proj_proj and to_k. Am I missing sth?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I missed that. I didn't check for sdxl turbo. It should be fine now if we first check for query and then for to_q.
Also, why are we not using load_weights here? Doesn't it help with such mapping issues?


# Map the mid block
if "mid_block.resnets.0" in key:
key = key.replace("mid_block.resnets.0", "mid_blocks.0")
Expand Down