diff options
author | Fampai <unknown> | 2022-10-09 08:32:40 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-09 19:31:23 +0000 |
commit | ad3ae441081155dcd4fde805279e5082ca264695 (patch) | |
tree | 018cabe6cab1c4fce8b80ffa38e84f347165a817 /modules/sd_hijack.py | |
parent | ec2bd9be75865c9f3a8c898163ab381688c03b6e (diff) | |
download | stable-diffusion-webui-gfx803-ad3ae441081155dcd4fde805279e5082ca264695.tar.gz stable-diffusion-webui-gfx803-ad3ae441081155dcd4fde805279e5082ca264695.tar.bz2 stable-diffusion-webui-gfx803-ad3ae441081155dcd4fde805279e5082ca264695.zip |
Updated code for legibility
Diffstat (limited to 'modules/sd_hijack.py')
-rw-r--r-- | modules/sd_hijack.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 4a2d2153..7793d25b 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -284,8 +284,11 @@ class FrozenCLIPEmbedderWithCustomWords(torch.nn.Module): tmp = -opts.CLIP_stop_at_last_layers
outputs = self.wrapped.transformer(input_ids=tokens, position_ids=position_ids, output_hidden_states=tmp)
- z = outputs.hidden_states[tmp]
- z = self.wrapped.transformer.text_model.final_layer_norm(z)
+ if tmp < -1:
+ z = outputs.hidden_states[tmp]
+ z = self.wrapped.transformer.text_model.final_layer_norm(z)
+ else:
+ z = outputs.last_hidden_state
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
batch_multipliers_of_same_length = [x + [1.0] * (target_token_count - len(x)) for x in batch_multipliers]
|