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
5272fd4b
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "047c9fe82c0e9ec4e38234315e2144bc13f5f408"
Commit
5272fd4b
authored
Apr 04, 2024
by
comfyanonymous
Browse files
Add DualCFGGuider used in IP2P models for example.
parent
cfbf3be5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
comfy_extras/nodes_custom_sampler.py
comfy_extras/nodes_custom_sampler.py
+36
-0
No files found.
comfy_extras/nodes_custom_sampler.py
View file @
5272fd4b
...
@@ -428,6 +428,41 @@ class CFGGuider:
...
@@ -428,6 +428,41 @@ class CFGGuider:
guider
.
set_cfg
(
cfg
)
guider
.
set_cfg
(
cfg
)
return
(
guider
,)
return
(
guider
,)
class
Guider_DualCFG
(
comfy
.
samplers
.
CFGGuider
):
def
set_cfg
(
self
,
cfg1
,
cfg2
):
self
.
cfg1
=
cfg1
self
.
cfg2
=
cfg2
def
set_conds
(
self
,
positive
,
middle
,
negative
):
self
.
inner_set_conds
({
"positive"
:
positive
,
"middle"
:
middle
,
"negative"
:
negative
})
def
predict_noise
(
self
,
x
,
timestep
,
model_options
=
{},
seed
=
None
):
out
=
comfy
.
samplers
.
calc_cond_batch
(
self
.
inner_model
,
[
self
.
conds
.
get
(
"negative"
,
None
),
self
.
conds
.
get
(
"middle"
,
None
),
self
.
conds
.
get
(
"positive"
,
None
)],
x
,
timestep
,
model_options
)
return
comfy
.
samplers
.
cfg_function
(
self
.
inner_model
,
out
[
1
],
out
[
0
],
self
.
cfg2
,
x
,
timestep
,
model_options
=
model_options
)
+
(
out
[
2
]
-
out
[
1
])
*
self
.
cfg1
class
DualCFGGuider
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"model"
:
(
"MODEL"
,),
"cond1"
:
(
"CONDITIONING"
,
),
"cond2"
:
(
"CONDITIONING"
,
),
"negative"
:
(
"CONDITIONING"
,
),
"cfg_conds"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
,
"step"
:
0.1
,
"round"
:
0.01
}),
"cfg_cond2_negative"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
,
"step"
:
0.1
,
"round"
:
0.01
}),
}
}
RETURN_TYPES
=
(
"GUIDER"
,)
FUNCTION
=
"get_guider"
CATEGORY
=
"sampling/custom_sampling/guiders"
def
get_guider
(
self
,
model
,
cond1
,
cond2
,
negative
,
cfg_conds
,
cfg_cond2_negative
):
guider
=
Guider_DualCFG
(
model
)
guider
.
set_conds
(
cond1
,
cond2
,
negative
)
guider
.
set_cfg
(
cfg_conds
,
cfg_cond2_negative
)
return
(
guider
,)
class
DisableNoise
:
class
DisableNoise
:
@
classmethod
@
classmethod
...
@@ -518,6 +553,7 @@ NODE_CLASS_MAPPINGS = {
...
@@ -518,6 +553,7 @@ NODE_CLASS_MAPPINGS = {
"FlipSigmas"
:
FlipSigmas
,
"FlipSigmas"
:
FlipSigmas
,
"CFGGuider"
:
CFGGuider
,
"CFGGuider"
:
CFGGuider
,
"DualCFGGuider"
:
DualCFGGuider
,
"BasicGuider"
:
BasicGuider
,
"BasicGuider"
:
BasicGuider
,
"RandomNoise"
:
RandomNoise
,
"RandomNoise"
:
RandomNoise
,
"DisableNoise"
:
DisableNoise
,
"DisableNoise"
:
DisableNoise
,
...
...
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