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
0f5768e0
Commit
0f5768e0
authored
Apr 04, 2024
by
comfyanonymous
Browse files
Fix missing arguments in cfg_function.
parent
1f4fc9ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
comfy/samplers.py
comfy/samplers.py
+2
-2
comfy_extras/nodes_custom_sampler.py
comfy_extras/nodes_custom_sampler.py
+5
-2
No files found.
comfy/samplers.py
View file @
0f5768e0
...
@@ -231,7 +231,7 @@ def calc_cond_uncond_batch(model, cond, uncond, x_in, timestep, model_options):
...
@@ -231,7 +231,7 @@ def calc_cond_uncond_batch(model, cond, uncond, x_in, timestep, model_options):
logging
.
warning
(
"WARNING: The comfy.samplers.calc_cond_uncond_batch function is deprecated please use the calc_cond_batch one instead."
)
logging
.
warning
(
"WARNING: The comfy.samplers.calc_cond_uncond_batch function is deprecated please use the calc_cond_batch one instead."
)
return
tuple
(
calc_cond_batch
(
model
,
[
cond
,
uncond
],
x_in
,
timestep
,
model_options
))
return
tuple
(
calc_cond_batch
(
model
,
[
cond
,
uncond
],
x_in
,
timestep
,
model_options
))
def
cfg_function
(
model
,
cond_pred
,
uncond_pred
,
cond_scale
,
x
,
timestep
,
model_options
=
{}):
def
cfg_function
(
model
,
cond_pred
,
uncond_pred
,
cond_scale
,
x
,
timestep
,
model_options
=
{}
,
cond
=
None
,
uncond
=
None
):
if
"sampler_cfg_function"
in
model_options
:
if
"sampler_cfg_function"
in
model_options
:
args
=
{
"cond"
:
x
-
cond_pred
,
"uncond"
:
x
-
uncond_pred
,
"cond_scale"
:
cond_scale
,
"timestep"
:
timestep
,
"input"
:
x
,
"sigma"
:
timestep
,
args
=
{
"cond"
:
x
-
cond_pred
,
"uncond"
:
x
-
uncond_pred
,
"cond_scale"
:
cond_scale
,
"timestep"
:
timestep
,
"input"
:
x
,
"sigma"
:
timestep
,
"cond_denoised"
:
cond_pred
,
"uncond_denoised"
:
uncond_pred
,
"model"
:
model
,
"model_options"
:
model_options
}
"cond_denoised"
:
cond_pred
,
"uncond_denoised"
:
uncond_pred
,
"model"
:
model
,
"model_options"
:
model_options
}
...
@@ -256,7 +256,7 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_option
...
@@ -256,7 +256,7 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_option
conds
=
[
cond
,
uncond_
]
conds
=
[
cond
,
uncond_
]
out
=
calc_cond_batch
(
model
,
conds
,
x
,
timestep
,
model_options
)
out
=
calc_cond_batch
(
model
,
conds
,
x
,
timestep
,
model_options
)
return
cfg_function
(
model
,
out
[
0
],
out
[
1
],
cond_scale
,
x
,
timestep
,
model_options
=
model_options
)
return
cfg_function
(
model
,
out
[
0
],
out
[
1
],
cond_scale
,
x
,
timestep
,
model_options
=
model_options
,
cond
=
cond
,
uncond
=
uncond_
)
class
KSamplerX0Inpaint
:
class
KSamplerX0Inpaint
:
...
...
comfy_extras/nodes_custom_sampler.py
View file @
0f5768e0
...
@@ -436,8 +436,11 @@ class Guider_DualCFG(comfy.samplers.CFGGuider):
...
@@ -436,8 +436,11 @@ class Guider_DualCFG(comfy.samplers.CFGGuider):
self
.
inner_set_conds
({
"positive"
:
positive
,
"middle"
:
middle
,
"negative"
:
negative
})
self
.
inner_set_conds
({
"positive"
:
positive
,
"middle"
:
middle
,
"negative"
:
negative
})
def
predict_noise
(
self
,
x
,
timestep
,
model_options
=
{},
seed
=
None
):
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
)
negative_cond
=
self
.
conds
.
get
(
"negative"
,
None
)
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
middle_cond
=
self
.
conds
.
get
(
"middle"
,
None
)
out
=
comfy
.
samplers
.
calc_cond_batch
(
self
.
inner_model
,
[
negative_cond
,
middle_cond
,
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
,
cond
=
middle_cond
,
uncond
=
negative_cond
)
+
(
out
[
2
]
-
out
[
1
])
*
self
.
cfg1
class
DualCFGGuider
:
class
DualCFGGuider
:
@
classmethod
@
classmethod
...
...
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