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
d3293c83
Commit
d3293c83
authored
May 01, 2023
by
comfyanonymous
Browse files
Properly disable all progress bars when disable_pbar=True
parent
cb3772bb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
+13
-10
comfy/extra_samplers/uni_pc.py
comfy/extra_samplers/uni_pc.py
+4
-4
comfy/ldm/models/diffusion/ddim.py
comfy/ldm/models/diffusion/ddim.py
+5
-3
comfy/sample.py
comfy/sample.py
+2
-2
comfy/samplers.py
comfy/samplers.py
+2
-1
No files found.
comfy/extra_samplers/uni_pc.py
View file @
d3293c83
...
...
@@ -712,7 +712,7 @@ class UniPC:
def
sample
(
self
,
x
,
timesteps
,
t_start
=
None
,
t_end
=
None
,
order
=
3
,
skip_type
=
'time_uniform'
,
method
=
'singlestep'
,
lower_order_final
=
True
,
denoise_to_zero
=
False
,
solver_type
=
'dpm_solver'
,
atol
=
0.0078
,
rtol
=
0.05
,
corrector
=
False
,
callback
=
None
atol
=
0.0078
,
rtol
=
0.05
,
corrector
=
False
,
callback
=
None
,
disable_pbar
=
False
):
t_0
=
1.
/
self
.
noise_schedule
.
total_N
if
t_end
is
None
else
t_end
t_T
=
self
.
noise_schedule
.
T
if
t_start
is
None
else
t_start
...
...
@@ -723,7 +723,7 @@ class UniPC:
# timesteps = self.get_time_steps(skip_type=skip_type, t_T=t_T, t_0=t_0, N=steps, device=device)
assert
timesteps
.
shape
[
0
]
-
1
==
steps
# with torch.no_grad():
for
step_index
in
trange
(
steps
):
for
step_index
in
trange
(
steps
,
disable
=
disable_pbar
):
if
self
.
noise_mask
is
not
None
:
x
=
x
*
self
.
noise_mask
+
(
1.
-
self
.
noise_mask
)
*
(
self
.
masked_image
*
self
.
noise_schedule
.
marginal_alpha
(
timesteps
[
step_index
])
+
self
.
noise
*
self
.
noise_schedule
.
marginal_std
(
timesteps
[
step_index
]))
if
step_index
==
0
:
...
...
@@ -835,7 +835,7 @@ def expand_dims(v, dims):
def
sample_unipc
(
model
,
noise
,
image
,
sigmas
,
sampling_function
,
max_denoise
,
extra_args
=
None
,
callback
=
None
,
disable
=
Non
e
,
noise_mask
=
None
,
variant
=
'bh1'
):
def
sample_unipc
(
model
,
noise
,
image
,
sigmas
,
sampling_function
,
max_denoise
,
extra_args
=
None
,
callback
=
None
,
disable
=
Fals
e
,
noise_mask
=
None
,
variant
=
'bh1'
):
to_zero
=
False
if
sigmas
[
-
1
]
==
0
:
timesteps
=
torch
.
nn
.
functional
.
interpolate
(
sigmas
[
None
,
None
,:
-
1
],
size
=
(
len
(
sigmas
),),
mode
=
'linear'
)[
0
][
0
]
...
...
@@ -879,7 +879,7 @@ def sample_unipc(model, noise, image, sigmas, sampling_function, max_denoise, ex
order
=
min
(
3
,
len
(
timesteps
)
-
1
)
uni_pc
=
UniPC
(
model_fn
,
ns
,
predict_x0
=
True
,
thresholding
=
False
,
noise_mask
=
noise_mask
,
masked_image
=
image
,
noise
=
noise
,
variant
=
variant
)
x
=
uni_pc
.
sample
(
img
,
timesteps
=
timesteps
,
skip_type
=
"time_uniform"
,
method
=
"multistep"
,
order
=
order
,
lower_order_final
=
True
,
callback
=
callback
)
x
=
uni_pc
.
sample
(
img
,
timesteps
=
timesteps
,
skip_type
=
"time_uniform"
,
method
=
"multistep"
,
order
=
order
,
lower_order_final
=
True
,
callback
=
callback
,
disable_pbar
=
disable
)
if
not
to_zero
:
x
/=
ns
.
marginal_alpha
(
timesteps
[
-
1
])
return
x
comfy/ldm/models/diffusion/ddim.py
View file @
d3293c83
...
...
@@ -81,6 +81,7 @@ class DDIMSampler(object):
extra_args
=
None
,
to_zero
=
True
,
end_step
=
None
,
disable_pbar
=
False
,
**
kwargs
):
self
.
make_schedule_timesteps
(
ddim_timesteps
=
ddim_timesteps
,
ddim_eta
=
eta
,
verbose
=
verbose
)
...
...
@@ -103,7 +104,8 @@ class DDIMSampler(object):
denoise_function
=
denoise_function
,
extra_args
=
extra_args
,
to_zero
=
to_zero
,
end_step
=
end_step
end_step
=
end_step
,
disable_pbar
=
disable_pbar
)
return
samples
,
intermediates
...
...
@@ -185,7 +187,7 @@ class DDIMSampler(object):
mask
=
None
,
x0
=
None
,
img_callback
=
None
,
log_every_t
=
100
,
temperature
=
1.
,
noise_dropout
=
0.
,
score_corrector
=
None
,
corrector_kwargs
=
None
,
unconditional_guidance_scale
=
1.
,
unconditional_conditioning
=
None
,
dynamic_threshold
=
None
,
ucg_schedule
=
None
,
denoise_function
=
None
,
extra_args
=
None
,
to_zero
=
True
,
end_step
=
None
):
ucg_schedule
=
None
,
denoise_function
=
None
,
extra_args
=
None
,
to_zero
=
True
,
end_step
=
None
,
disable_pbar
=
False
):
device
=
self
.
model
.
betas
.
device
b
=
shape
[
0
]
if
x_T
is
None
:
...
...
@@ -204,7 +206,7 @@ class DDIMSampler(object):
total_steps
=
timesteps
if
ddim_use_original_steps
else
timesteps
.
shape
[
0
]
# print(f"Running DDIM Sampling with {total_steps} timesteps")
iterator
=
tqdm
(
time_range
[:
end_step
],
desc
=
'DDIM Sampler'
,
total
=
end_step
)
iterator
=
tqdm
(
time_range
[:
end_step
],
desc
=
'DDIM Sampler'
,
total
=
end_step
,
disable
=
disable_pbar
)
for
i
,
step
in
enumerate
(
iterator
):
index
=
total_steps
-
i
-
1
...
...
comfy/sample.py
View file @
d3293c83
...
...
@@ -56,7 +56,7 @@ def cleanup_additional_models(models):
for
m
in
models
:
m
.
cleanup
()
def
sample
(
model
,
noise
,
steps
,
cfg
,
sampler_name
,
scheduler
,
positive
,
negative
,
latent_image
,
denoise
=
1.0
,
disable_noise
=
False
,
start_step
=
None
,
last_step
=
None
,
force_full_denoise
=
False
,
noise_mask
=
None
,
sigmas
=
None
,
callback
=
None
):
def
sample
(
model
,
noise
,
steps
,
cfg
,
sampler_name
,
scheduler
,
positive
,
negative
,
latent_image
,
denoise
=
1.0
,
disable_noise
=
False
,
start_step
=
None
,
last_step
=
None
,
force_full_denoise
=
False
,
noise_mask
=
None
,
sigmas
=
None
,
callback
=
None
,
disable_pbar
=
False
):
device
=
comfy
.
model_management
.
get_torch_device
()
if
noise_mask
is
not
None
:
...
...
@@ -76,7 +76,7 @@ def sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative
sampler
=
comfy
.
samplers
.
KSampler
(
real_model
,
steps
=
steps
,
device
=
device
,
sampler
=
sampler_name
,
scheduler
=
scheduler
,
denoise
=
denoise
,
model_options
=
model
.
model_options
)
samples
=
sampler
.
sample
(
noise
,
positive_copy
,
negative_copy
,
cfg
=
cfg
,
latent_image
=
latent_image
,
start_step
=
start_step
,
last_step
=
last_step
,
force_full_denoise
=
force_full_denoise
,
denoise_mask
=
noise_mask
,
sigmas
=
sigmas
,
callback
=
callback
)
samples
=
sampler
.
sample
(
noise
,
positive_copy
,
negative_copy
,
cfg
=
cfg
,
latent_image
=
latent_image
,
start_step
=
start_step
,
last_step
=
last_step
,
force_full_denoise
=
force_full_denoise
,
denoise_mask
=
noise_mask
,
sigmas
=
sigmas
,
callback
=
callback
,
disable_pbar
=
disable_pbar
)
samples
=
samples
.
cpu
()
cleanup_additional_models
(
models
)
...
...
comfy/samplers.py
View file @
d3293c83
...
...
@@ -643,7 +643,8 @@ class KSampler:
extra_args
=
extra_args
,
mask
=
noise_mask
,
to_zero
=
sigmas
[
-
1
]
==
0
,
end_step
=
sigmas
.
shape
[
0
]
-
1
)
end_step
=
sigmas
.
shape
[
0
]
-
1
,
disable_pbar
=
disable_pbar
)
else
:
extra_args
[
"denoise_mask"
]
=
denoise_mask
...
...
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