MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / conv_attn_to_linear

Function conv_attn_to_linear

scripts/convert_zero123_to_diffusers.py:669–678  ·  view source on GitHub ↗
(checkpoint)

Source from the content-addressed store, hash-verified

667
668
669def conv_attn_to_linear(checkpoint):
670 keys = list(checkpoint.keys())
671 attn_keys = ["query.weight", "key.weight", "value.weight"]
672 for key in keys:
673 if ".".join(key.split(".")[-2:]) in attn_keys:
674 if checkpoint[key].ndim > 2:
675 checkpoint[key] = checkpoint[key][:, :, 0, 0]
676 elif "proj_attn.weight" in key:
677 if checkpoint[key].ndim > 2:
678 checkpoint[key] = checkpoint[key][:, :, 0]
679
680
681def 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