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
388567f2
Commit
388567f2
authored
Jun 13, 2023
by
comfyanonymous
Browse files
sampler_cfg_function now uses a dict for the argument.
This means arguments can be added without issues.
parent
d52ed407
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
comfy/samplers.py
comfy/samplers.py
+2
-1
comfy/sd.py
comfy/sd.py
+5
-2
No files found.
comfy/samplers.py
View file @
388567f2
...
@@ -273,7 +273,8 @@ def sampling_function(model_function, x, timestep, uncond, cond, cond_scale, con
...
@@ -273,7 +273,8 @@ 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
)
if
"sampler_cfg_function"
in
model_options
:
if
"sampler_cfg_function"
in
model_options
:
return
model_options
[
"sampler_cfg_function"
](
cond
,
uncond
,
cond_scale
)
args
=
{
"cond"
:
cond
,
"uncond"
:
uncond
,
"cond_scale"
:
cond_scale
,
"timestep"
:
timestep
}
return
model_options
[
"sampler_cfg_function"
](
args
)
else
:
else
:
return
uncond
+
(
cond
-
uncond
)
*
cond_scale
return
uncond
+
(
cond
-
uncond
)
*
cond_scale
...
...
comfy/sd.py
View file @
388567f2
import
torch
import
torch
import
contextlib
import
contextlib
import
copy
import
copy
import
inspect
from
.
import
sd1_clip
from
.
import
sd1_clip
from
.
import
sd2_clip
from
.
import
sd2_clip
...
@@ -313,9 +314,11 @@ class ModelPatcher:
...
@@ -313,9 +314,11 @@ class ModelPatcher:
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
):
def
set_model_sampler_cfg_function
(
self
,
sampler_cfg_function
):
if
len
(
inspect
.
signature
(
sampler_cfg_function
).
parameters
)
==
3
:
self
.
model_options
[
"sampler_cfg_function"
]
=
lambda
args
:
sampler_cfg_function
(
args
[
"cond"
],
args
[
"uncond"
],
args
[
"cond_scale"
])
#Old way
else
:
self
.
model_options
[
"sampler_cfg_function"
]
=
sampler_cfg_function
self
.
model_options
[
"sampler_cfg_function"
]
=
sampler_cfg_function
def
set_model_patch
(
self
,
patch
,
name
):
def
set_model_patch
(
self
,
patch
,
name
):
to
=
self
.
model_options
[
"transformer_options"
]
to
=
self
.
model_options
[
"transformer_options"
]
if
"patches"
not
in
to
:
if
"patches"
not
in
to
:
...
...
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