diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-29 12:40:28 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-29 12:40:28 +0000 |
commit | c715ef04d1edb1a112a602639ed3bb292fdeb0e2 (patch) | |
tree | 30bd6137b21e771f920bee3f23cd5a7d51fa78c3 /modules/sd_hijack.py | |
parent | 965dcf446991eca02074a9666048f50540261ba5 (diff) | |
download | stable-diffusion-webui-gfx803-c715ef04d1edb1a112a602639ed3bb292fdeb0e2.tar.gz stable-diffusion-webui-gfx803-c715ef04d1edb1a112a602639ed3bb292fdeb0e2.tar.bz2 stable-diffusion-webui-gfx803-c715ef04d1edb1a112a602639ed3bb292fdeb0e2.zip |
fix for incorrect model weight loading for #814
Diffstat (limited to 'modules/sd_hijack.py')
-rw-r--r-- | modules/sd_hijack.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 2848a251..5945b7c2 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -245,6 +245,7 @@ class StableDiffusionModelHijack: model_embeddings.token_embedding = EmbeddingsWithFixes(model_embeddings.token_embedding, self)
m.cond_stage_model = FrozenCLIPEmbedderWithCustomWords(m.cond_stage_model, self)
+
self.clip = m.cond_stage_model
if cmd_opts.opt_split_attention_v1:
@@ -263,6 +264,14 @@ class StableDiffusionModelHijack: self.layers = flatten(m)
+ def undo_hijack(self, m):
+ if type(m.cond_stage_model) == FrozenCLIPEmbedderWithCustomWords:
+ m.cond_stage_model = m.cond_stage_model.wrapped
+
+ model_embeddings = m.cond_stage_model.transformer.text_model.embeddings
+ if type(model_embeddings.token_embedding) == EmbeddingsWithFixes:
+ model_embeddings.token_embedding = model_embeddings.token_embedding.wrapped
+
def apply_circular(self, enable):
if self.circular_enabled == enable:
return
|