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
d94ddd85
Commit
d94ddd85
authored
Jul 03, 2023
by
comfyanonymous
Browse files
Add text encode nodes to control the extra parameters in SDXL.
parent
c3e96e63
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
comfy_extras/nodes_clip_sdxl.py
comfy_extras/nodes_clip_sdxl.py
+50
-0
nodes.py
nodes.py
+1
-0
No files found.
comfy_extras/nodes_clip_sdxl.py
0 → 100644
View file @
d94ddd85
import
torch
from
nodes
import
MAX_RESOLUTION
class
CLIPTextEncodeSDXLRefiner
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"ascore"
:
(
"FLOAT"
,
{
"default"
:
6.0
,
"min"
:
0.0
,
"max"
:
1000.0
,
"step"
:
0.01
}),
"width"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"height"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"text"
:
(
"STRING"
,
{
"multiline"
:
True
}),
"clip"
:
(
"CLIP"
,
),
}}
RETURN_TYPES
=
(
"CONDITIONING"
,)
FUNCTION
=
"encode"
CATEGORY
=
"advanced/conditioning"
def
encode
(
self
,
clip
,
ascore
,
width
,
height
,
text
):
tokens
=
clip
.
tokenize
(
text
)
cond
,
pooled
=
clip
.
encode_from_tokens
(
tokens
,
return_pooled
=
True
)
return
([[
cond
,
{
"pooled_output"
:
pooled
,
"aesthetic_score"
:
ascore
,
"width"
:
width
,
"height"
:
height
}]],
)
class
CLIPTextEncodeSDXL
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"width"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"height"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"crop_w"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"crop_h"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"target_width"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"target_height"
:
(
"INT"
,
{
"default"
:
1024.0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
}),
"text_g"
:
(
"STRING"
,
{
"multiline"
:
True
,
"default"
:
"CLIP_G"
}),
"clip"
:
(
"CLIP"
,
),
"text_l"
:
(
"STRING"
,
{
"multiline"
:
True
,
"default"
:
"CLIP_L"
}),
"clip"
:
(
"CLIP"
,
),
}}
RETURN_TYPES
=
(
"CONDITIONING"
,)
FUNCTION
=
"encode"
CATEGORY
=
"advanced/conditioning"
def
encode
(
self
,
clip
,
width
,
height
,
crop_w
,
crop_h
,
target_width
,
target_height
,
text_g
,
text_l
):
tokens
=
clip
.
tokenize
(
text_g
)
tokens
[
"l"
]
=
clip
.
tokenize
(
text_l
)[
"l"
]
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
}]],
)
NODE_CLASS_MAPPINGS
=
{
"CLIPTextEncodeSDXLRefiner"
:
CLIPTextEncodeSDXLRefiner
,
"CLIPTextEncodeSDXL"
:
CLIPTextEncodeSDXL
,
}
nodes.py
View file @
d94ddd85
...
...
@@ -1501,4 +1501,5 @@ def init_custom_nodes():
load_custom_node
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"comfy_extras"
),
"nodes_rebatch.py"
))
load_custom_node
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"comfy_extras"
),
"nodes_model_merging.py"
))
load_custom_node
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"comfy_extras"
),
"nodes_tomesd.py"
))
load_custom_node
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"comfy_extras"
),
"nodes_clip_sdxl.py"
))
load_custom_nodes
()
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