(model, patch_kwargs, key)
| 208 | self.to_kvs[key.replace(".weight", "").replace(".", "_")].weight.data = value |
| 209 | |
| 210 | def set_model_patch_replace(model, patch_kwargs, key): |
| 211 | to = model.model_options["transformer_options"].copy() |
| 212 | if "patches_replace" not in to: |
| 213 | to["patches_replace"] = {} |
| 214 | else: |
| 215 | to["patches_replace"] = to["patches_replace"].copy() |
| 216 | |
| 217 | if "attn2" not in to["patches_replace"]: |
| 218 | to["patches_replace"]["attn2"] = {} |
| 219 | else: |
| 220 | to["patches_replace"]["attn2"] = to["patches_replace"]["attn2"].copy() |
| 221 | |
| 222 | if key not in to["patches_replace"]["attn2"]: |
| 223 | to["patches_replace"]["attn2"][key] = Attn2Replace(ipadapter_attention, **patch_kwargs) |
| 224 | model.model_options["transformer_options"] = to |
| 225 | else: |
| 226 | to["patches_replace"]["attn2"][key].add(ipadapter_attention, **patch_kwargs) |
| 227 | |
| 228 | def ipadapter_execute(model, |
| 229 | ipadapter, |
no test coverage detected