aboutsummaryrefslogtreecommitdiffstats
path: root/modules/sd_hijack_clip.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-07-13 08:35:52 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2023-07-13 08:35:52 +0000
commit594c8e7b263d9b37f4b18b56b159aeb6d1bba1b4 (patch)
tree274143ec746dcc454c3b0b5b094abf688d2da676 /modules/sd_hijack_clip.py
parent21aec6f567f52271efbbe33a2ab6561f9a47b787 (diff)
downloadstable-diffusion-webui-gfx803-594c8e7b263d9b37f4b18b56b159aeb6d1bba1b4.tar.gz
stable-diffusion-webui-gfx803-594c8e7b263d9b37f4b18b56b159aeb6d1bba1b4.tar.bz2
stable-diffusion-webui-gfx803-594c8e7b263d9b37f4b18b56b159aeb6d1bba1b4.zip
fix CLIP doing the unneeded normalization
revert SD2.1 back to use the original repo add SDXL's force_zero_embeddings to negative prompt
Diffstat (limited to 'modules/sd_hijack_clip.py')
-rw-r--r--modules/sd_hijack_clip.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/sd_hijack_clip.py b/modules/sd_hijack_clip.py
index 6c17a81d..b3771909 100644
--- a/modules/sd_hijack_clip.py
+++ b/modules/sd_hijack_clip.py
@@ -323,3 +323,18 @@ class FrozenCLIPEmbedderWithCustomWords(FrozenCLIPEmbedderWithCustomWordsBase):
embedded = embedding_layer.token_embedding.wrapped(ids.to(embedding_layer.token_embedding.wrapped.weight.device)).squeeze(0)
return embedded
+
+
+class FrozenCLIPEmbedderForSDXLWithCustomWords(FrozenCLIPEmbedderWithCustomWords):
+ def __init__(self, wrapped, hijack):
+ super().__init__(wrapped, hijack)
+
+ def encode_with_transformers(self, tokens):
+ outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=self.wrapped.layer == "hidden")
+
+ if self.wrapped.layer == "last":
+ z = outputs.last_hidden_state
+ else:
+ z = outputs.hidden_states[self.wrapped.layer_idx]
+
+ return z