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
6c5990f7
Commit
6c5990f7
authored
Dec 13, 2023
by
comfyanonymous
Browse files
Fix cfg being calculated more than once if sampler_cfg_function.
parent
ba04a87d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
comfy/samplers.py
comfy/samplers.py
+2
-1
No files found.
comfy/samplers.py
View file @
6c5990f7
...
@@ -250,10 +250,11 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_option
...
@@ -250,10 +250,11 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_option
uncond_
=
uncond
uncond_
=
uncond
cond_pred
,
uncond_pred
=
calc_cond_uncond_batch
(
model
,
cond
,
uncond_
,
x
,
timestep
,
model_options
)
cond_pred
,
uncond_pred
=
calc_cond_uncond_batch
(
model
,
cond
,
uncond_
,
x
,
timestep
,
model_options
)
cfg_result
=
uncond_pred
+
(
cond_pred
-
uncond_pred
)
*
cond_scale
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
}
cfg_result
=
x
-
model_options
[
"sampler_cfg_function"
](
args
)
cfg_result
=
x
-
model_options
[
"sampler_cfg_function"
](
args
)
else
:
cfg_result
=
uncond_pred
+
(
cond_pred
-
uncond_pred
)
*
cond_scale
for
fn
in
model_options
.
get
(
"sampler_post_cfg_function"
,
[]):
for
fn
in
model_options
.
get
(
"sampler_post_cfg_function"
,
[]):
args
=
{
"denoised"
:
cfg_result
,
"cond"
:
cond
,
"uncond"
:
uncond
,
"model"
:
model
,
"uncond_denoised"
:
uncond_pred
,
"cond_denoised"
:
cond_pred
,
args
=
{
"denoised"
:
cfg_result
,
"cond"
:
cond
,
"uncond"
:
uncond
,
"model"
:
model
,
"uncond_denoised"
:
uncond_pred
,
"cond_denoised"
:
cond_pred
,
...
...
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