Fix attention layers map for SD-2-1-Base#971
Fix attention layers map for SD-2-1-Base#971pranav4501 wants to merge 2 commits intoml-explore:mainfrom
Conversation
| if "query" in key: | ||
| key = key.replace("query", "query_proj") | ||
| if "value" in key: | ||
| key = key.replace("value", "value_proj") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
|
Hi @pranav4501 could you give an example of what wasn't working and what this fixes? I will take a closer look but I would appreciate sth like Thanks and sorry if I am putting extra work on you. |
|
Hi @angeloskath , Sorry for the late response. You will have to make a couple changes to model_io.py of stable diffusion model.load_weights(list(weights),strict=True)
python3 txt2image.py "A photo of an astronaut riding a horse on Mars." --n_images 1 --steps 1 --model sd
ValueError: Received parameters not in model: encoder.mid_blocks.1.proj_attn.weight encoder.mid_blocks.1.value.bias decoder.mid_blocks.1.proj_attn.bias decoder.mid_blocks.1.value.bias |
The safetensors are not mapped correctly for attention layers of SD-2-1-base.