(model, patch_kwargs, key)
| 118 | self.to_kvs[k].weight.data = value |
| 119 | |
| 120 | def _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 | |
| 138 | class InstantIDModelLoader: |
| 139 | @classmethod |
no test coverage detected