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
884ea653
Commit
884ea653
authored
Apr 17, 2023
by
comfyanonymous
Browse files
Add a way for nodes to set a custom CFG function.
parent
0ab5c619
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
comfy/samplers.py
comfy/samplers.py
+4
-1
comfy/sd.py
comfy/sd.py
+3
-0
No files found.
comfy/samplers.py
View file @
884ea653
...
@@ -211,7 +211,10 @@ def sampling_function(model_function, x, timestep, uncond, cond, cond_scale, con
...
@@ -211,7 +211,10 @@ def sampling_function(model_function, x, timestep, uncond, cond, cond_scale, con
max_total_area
=
model_management
.
maximum_batch_area
()
max_total_area
=
model_management
.
maximum_batch_area
()
cond
,
uncond
=
calc_cond_uncond_batch
(
model_function
,
cond
,
uncond
,
x
,
timestep
,
max_total_area
,
cond_concat
,
model_options
)
cond
,
uncond
=
calc_cond_uncond_batch
(
model_function
,
cond
,
uncond
,
x
,
timestep
,
max_total_area
,
cond_concat
,
model_options
)
return
uncond
+
(
cond
-
uncond
)
*
cond_scale
if
"sampler_cfg_function"
in
model_options
:
return
model_options
[
"sampler_cfg_function"
](
cond
,
uncond
,
cond_scale
)
else
:
return
uncond
+
(
cond
-
uncond
)
*
cond_scale
class
CompVisVDenoiser
(
k_diffusion_external
.
DiscreteVDDPMDenoiser
):
class
CompVisVDenoiser
(
k_diffusion_external
.
DiscreteVDDPMDenoiser
):
...
...
comfy/sd.py
View file @
884ea653
...
@@ -250,6 +250,9 @@ class ModelPatcher:
...
@@ -250,6 +250,9 @@ class ModelPatcher:
def
set_model_tomesd
(
self
,
ratio
):
def
set_model_tomesd
(
self
,
ratio
):
self
.
model_options
[
"transformer_options"
][
"tomesd"
]
=
{
"ratio"
:
ratio
}
self
.
model_options
[
"transformer_options"
][
"tomesd"
]
=
{
"ratio"
:
ratio
}
def
set_model_sampler_cfg_function
(
self
,
sampler_cfg_function
):
self
.
model_options
[
"sampler_cfg_function"
]
=
sampler_cfg_function
def
model_dtype
(
self
):
def
model_dtype
(
self
):
return
self
.
model
.
diffusion_model
.
dtype
return
self
.
model
.
diffusion_model
.
dtype
...
...
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