MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / conv_attn_to_linear

Function conv_attn_to_linear

diffusers/scripts/convert_zero123_to_diffusers.py:670–679  ·  view source on GitHub ↗
(checkpoint)

Source from the content-addressed store, hash-verified

668
669
670def conv_attn_to_linear(checkpoint):
671 keys = list(checkpoint.keys())
672 attn_keys = ["query.weight", "key.weight", "value.weight"]
673 for key in keys:
674 if ".".join(key.split(".")[-2:]) in attn_keys:
675 if checkpoint[key].ndim > 2:
676 checkpoint[key] = checkpoint[key][:, :, 0, 0]
677 elif "proj_attn.weight" in key:
678 if checkpoint[key].ndim > 2:
679 checkpoint[key] = checkpoint[key][:, :, 0]
680
681
682def convert_from_original_zero123_ckpt(checkpoint_path, original_config_file, extract_ema, device):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected