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
908dc1d5
"doc/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "e82f000a01e07702a0488ce0049af53f5217329f"
Commit
908dc1d5
authored
May 03, 2023
by
comfyanonymous
Browse files
Add a total_steps value to sampler callback.
parent
93c64afa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
7 deletions
+11
-7
comfy/extra_samplers/uni_pc.py
comfy/extra_samplers/uni_pc.py
+1
-1
comfy/samplers.py
comfy/samplers.py
+5
-3
comfy/utils.py
comfy/utils.py
+3
-1
nodes.py
nodes.py
+2
-2
No files found.
comfy/extra_samplers/uni_pc.py
View file @
908dc1d5
...
...
@@ -767,7 +767,7 @@ class UniPC:
model_x
=
self
.
model_fn
(
x
,
vec_t
)
model_prev_list
[
-
1
]
=
model_x
if
callback
is
not
None
:
callback
(
step_index
,
model_prev_list
[
-
1
],
x
)
callback
(
step_index
,
model_prev_list
[
-
1
],
x
,
steps
)
else
:
raise
NotImplementedError
()
if
denoise_to_zero
:
...
...
comfy/samplers.py
View file @
908dc1d5
...
...
@@ -623,7 +623,8 @@ class KSampler:
ddim_callback
=
None
if
callback
is
not
None
:
ddim_callback
=
lambda
pred_x0
,
i
:
callback
(
i
,
pred_x0
,
None
)
total_steps
=
len
(
timesteps
)
-
1
ddim_callback
=
lambda
pred_x0
,
i
:
callback
(
i
,
pred_x0
,
None
,
total_steps
)
sampler
=
DDIMSampler
(
self
.
model
,
device
=
self
.
device
)
sampler
.
make_schedule_timesteps
(
ddim_timesteps
=
timesteps
,
verbose
=
False
)
...
...
@@ -654,13 +655,14 @@ class KSampler:
noise
=
noise
*
sigmas
[
0
]
k_callback
=
None
total_steps
=
len
(
sigmas
)
-
1
if
callback
is
not
None
:
k_callback
=
lambda
x
:
callback
(
x
[
"i"
],
x
[
"denoised"
],
x
[
"x"
])
k_callback
=
lambda
x
:
callback
(
x
[
"i"
],
x
[
"denoised"
],
x
[
"x"
]
,
total_steps
)
if
latent_image
is
not
None
:
noise
+=
latent_image
if
self
.
sampler
==
"dpm_fast"
:
samples
=
k_diffusion_sampling
.
sample_dpm_fast
(
self
.
model_k
,
noise
,
sigma_min
,
sigmas
[
0
],
self
.
steps
,
extra_args
=
extra_args
,
callback
=
k_callback
,
disable
=
disable_pbar
)
samples
=
k_diffusion_sampling
.
sample_dpm_fast
(
self
.
model_k
,
noise
,
sigma_min
,
sigmas
[
0
],
total_
steps
,
extra_args
=
extra_args
,
callback
=
k_callback
,
disable
=
disable_pbar
)
elif
self
.
sampler
==
"dpm_adaptive"
:
samples
=
k_diffusion_sampling
.
sample_dpm_adaptive
(
self
.
model_k
,
noise
,
sigma_min
,
sigmas
[
0
],
extra_args
=
extra_args
,
callback
=
k_callback
,
disable
=
disable_pbar
)
else
:
...
...
comfy/utils.py
View file @
908dc1d5
...
...
@@ -100,7 +100,9 @@ class ProgressBar:
self
.
current
=
0
self
.
hook
=
PROGRESS_BAR_HOOK
def
update_absolute
(
self
,
value
):
def
update_absolute
(
self
,
value
,
total
=
None
):
if
total
is
not
None
:
self
.
total
=
total
if
value
>
self
.
total
:
value
=
self
.
total
self
.
current
=
value
...
...
nodes.py
View file @
908dc1d5
...
...
@@ -816,8 +816,8 @@ def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive,
noise_mask
=
latent
[
"noise_mask"
]
pbar
=
comfy
.
utils
.
ProgressBar
(
steps
)
def
callback
(
step
,
x0
,
x
):
pbar
.
update_absolute
(
step
+
1
)
def
callback
(
step
,
x0
,
x
,
total_steps
):
pbar
.
update_absolute
(
step
+
1
,
total_steps
)
samples
=
comfy
.
sample
.
sample
(
model
,
noise
,
steps
,
cfg
,
sampler_name
,
scheduler
,
positive
,
negative
,
latent_image
,
denoise
=
denoise
,
disable_noise
=
disable_noise
,
start_step
=
start_step
,
last_step
=
last_step
,
...
...
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