MCPcopy
hub / github.com/cubiq/ComfyUI_InstantID / _set_model_patch_replace

Function _set_model_patch_replace

InstantID.py:120–136  ·  view source on GitHub ↗
(model, patch_kwargs, key)

Source from the content-addressed store, hash-verified

118 self.to_kvs[k].weight.data = value
119
120def _set_model_patch_replace(model, patch_kwargs, key):
121 to = model.model_options["transformer_options"].copy()
122 if "patches_replace" not in to:
123 to["patches_replace"] = {}
124 else:
125 to["patches_replace"] = to["patches_replace"].copy()
126
127 if "attn2" not in to["patches_replace"]:
128 to["patches_replace"]["attn2"] = {}
129 else:
130 to["patches_replace"]["attn2"] = to["patches_replace"]["attn2"].copy()
131
132 if key not in to["patches_replace"]["attn2"]:
133 to["patches_replace"]["attn2"][key] = Attn2Replace(instantid_attention, **patch_kwargs)
134 model.model_options["transformer_options"] = to
135 else:
136 to["patches_replace"]["attn2"][key].add(instantid_attention, **patch_kwargs)
137
138class InstantIDModelLoader:
139 @classmethod

Callers 2

apply_instantidMethod · 0.85
patch_attentionMethod · 0.85

Calls 2

Attn2ReplaceClass · 0.85
addMethod · 0.80

Tested by

no test coverage detected