Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
56333d48
Commit
56333d48
authored
Jun 07, 2024
by
comfyanonymous
Browse files
Use the end token for the text encoder attention mask.
parent
0dccb461
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
comfy/sd1_clip.py
comfy/sd1_clip.py
+2
-2
No files found.
comfy/sd1_clip.py
View file @
56333d48
...
@@ -168,11 +168,11 @@ class SDClipModel(torch.nn.Module, ClipTokenWeightEncoder):
...
@@ -168,11 +168,11 @@ class SDClipModel(torch.nn.Module, ClipTokenWeightEncoder):
attention_mask
=
None
attention_mask
=
None
if
self
.
enable_attention_masks
:
if
self
.
enable_attention_masks
:
attention_mask
=
torch
.
zeros_like
(
tokens
)
attention_mask
=
torch
.
zeros_like
(
tokens
)
max
_token
=
self
.
transformer
.
get_input_embeddings
().
weight
.
shape
[
0
]
-
1
end
_token
=
self
.
special_tokens
.
get
(
"end"
,
-
1
)
for
x
in
range
(
attention_mask
.
shape
[
0
]):
for
x
in
range
(
attention_mask
.
shape
[
0
]):
for
y
in
range
(
attention_mask
.
shape
[
1
]):
for
y
in
range
(
attention_mask
.
shape
[
1
]):
attention_mask
[
x
,
y
]
=
1
attention_mask
[
x
,
y
]
=
1
if
tokens
[
x
,
y
]
==
max
_token
:
if
tokens
[
x
,
y
]
==
end
_token
:
break
break
outputs
=
self
.
transformer
(
tokens
,
attention_mask
,
intermediate_output
=
self
.
layer_idx
,
final_layer_norm_intermediate
=
self
.
layer_norm_hidden_state
)
outputs
=
self
.
transformer
(
tokens
,
attention_mask
,
intermediate_output
=
self
.
layer_idx
,
final_layer_norm_intermediate
=
self
.
layer_norm_hidden_state
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment