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
2c9d98f3
"deploy/vscode:/vscode.git/clone" did not exist on "5a2b578e753a1e75d886a43642a04c073a85b364"
Commit
2c9d98f3
authored
Jul 06, 2023
by
comfyanonymous
Browse files
CLIPTextEncodeSDXL now works when prompts are of very different sizes.
parent
e7bee85d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
comfy_extras/nodes_clip_sdxl.py
comfy_extras/nodes_clip_sdxl.py
+6
-0
No files found.
comfy_extras/nodes_clip_sdxl.py
View file @
2c9d98f3
...
@@ -41,6 +41,12 @@ class CLIPTextEncodeSDXL:
...
@@ -41,6 +41,12 @@ class CLIPTextEncodeSDXL:
def
encode
(
self
,
clip
,
width
,
height
,
crop_w
,
crop_h
,
target_width
,
target_height
,
text_g
,
text_l
):
def
encode
(
self
,
clip
,
width
,
height
,
crop_w
,
crop_h
,
target_width
,
target_height
,
text_g
,
text_l
):
tokens
=
clip
.
tokenize
(
text_g
)
tokens
=
clip
.
tokenize
(
text_g
)
tokens
[
"l"
]
=
clip
.
tokenize
(
text_l
)[
"l"
]
tokens
[
"l"
]
=
clip
.
tokenize
(
text_l
)[
"l"
]
if
len
(
tokens
[
"l"
])
!=
len
(
tokens
[
"g"
]):
empty
=
clip
.
tokenize
(
""
)
while
len
(
tokens
[
"l"
])
<
len
(
tokens
[
"g"
]):
tokens
[
"l"
]
+=
empty
[
"l"
]
while
len
(
tokens
[
"l"
])
>
len
(
tokens
[
"g"
]):
tokens
[
"g"
]
+=
empty
[
"g"
]
cond
,
pooled
=
clip
.
encode_from_tokens
(
tokens
,
return_pooled
=
True
)
cond
,
pooled
=
clip
.
encode_from_tokens
(
tokens
,
return_pooled
=
True
)
return
([[
cond
,
{
"pooled_output"
:
pooled
,
"width"
:
width
,
"height"
:
height
,
"crop_w"
:
crop_w
,
"crop_h"
:
crop_h
,
"target_width"
:
target_width
,
"target_height"
:
target_height
}]],
)
return
([[
cond
,
{
"pooled_output"
:
pooled
,
"width"
:
width
,
"height"
:
height
,
"crop_w"
:
crop_w
,
"crop_h"
:
crop_h
,
"target_width"
:
target_width
,
"target_height"
:
target_height
}]],
)
...
...
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