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
e244b2df
Commit
e244b2df
authored
Aug 14, 2023
by
comfyanonymous
Browse files
Add sgm_uniform scheduler that acts like the default one in sgm.
parent
58c7da36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
comfy/samplers.py
comfy/samplers.py
+14
-1
No files found.
comfy/samplers.py
View file @
e244b2df
...
@@ -347,6 +347,17 @@ def ddim_scheduler(model, steps):
...
@@ -347,6 +347,17 @@ def ddim_scheduler(model, steps):
sigs
+=
[
0.0
]
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
return
torch
.
FloatTensor
(
sigs
)
def
sgm_scheduler
(
model
,
steps
):
sigs
=
[]
timesteps
=
torch
.
linspace
(
model
.
inner_model
.
inner_model
.
num_timesteps
-
1
,
0
,
steps
+
1
)[:
-
1
].
type
(
torch
.
int
)
for
x
in
range
(
len
(
timesteps
)):
ts
=
timesteps
[
x
]
if
ts
>
999
:
ts
=
999
sigs
.
append
(
model
.
t_to_sigma
(
torch
.
tensor
(
ts
)))
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
def
blank_inpaint_image_like
(
latent_image
):
def
blank_inpaint_image_like
(
latent_image
):
blank_image
=
torch
.
ones_like
(
latent_image
)
blank_image
=
torch
.
ones_like
(
latent_image
)
# these are the values for "zero" in pixel space translated to latent space
# these are the values for "zero" in pixel space translated to latent space
...
@@ -525,7 +536,7 @@ def encode_adm(model, conds, batch_size, width, height, device, prompt_type):
...
@@ -525,7 +536,7 @@ def encode_adm(model, conds, batch_size, width, height, device, prompt_type):
class
KSampler
:
class
KSampler
:
SCHEDULERS
=
[
"normal"
,
"karras"
,
"exponential"
,
"simple"
,
"ddim_uniform"
]
SCHEDULERS
=
[
"normal"
,
"karras"
,
"exponential"
,
"sgm_uniform"
,
"simple"
,
"ddim_uniform"
]
SAMPLERS
=
[
"euler"
,
"euler_ancestral"
,
"heun"
,
"dpm_2"
,
"dpm_2_ancestral"
,
SAMPLERS
=
[
"euler"
,
"euler_ancestral"
,
"heun"
,
"dpm_2"
,
"dpm_2_ancestral"
,
"lms"
,
"dpm_fast"
,
"dpm_adaptive"
,
"dpmpp_2s_ancestral"
,
"dpmpp_sde"
,
"dpmpp_sde_gpu"
,
"lms"
,
"dpm_fast"
,
"dpm_adaptive"
,
"dpmpp_2s_ancestral"
,
"dpmpp_sde"
,
"dpmpp_sde_gpu"
,
"dpmpp_2m"
,
"dpmpp_2m_sde"
,
"dpmpp_2m_sde_gpu"
,
"dpmpp_3m"
,
"dpmpp_3m_sde"
,
"dpmpp_3m_sde_gpu"
,
"ddim"
,
"uni_pc"
,
"uni_pc_bh2"
]
"dpmpp_2m"
,
"dpmpp_2m_sde"
,
"dpmpp_2m_sde_gpu"
,
"dpmpp_3m"
,
"dpmpp_3m_sde"
,
"dpmpp_3m_sde_gpu"
,
"ddim"
,
"uni_pc"
,
"uni_pc_bh2"
]
...
@@ -570,6 +581,8 @@ class KSampler:
...
@@ -570,6 +581,8 @@ class KSampler:
sigmas
=
simple_scheduler
(
self
.
model_wrap
,
steps
)
sigmas
=
simple_scheduler
(
self
.
model_wrap
,
steps
)
elif
self
.
scheduler
==
"ddim_uniform"
:
elif
self
.
scheduler
==
"ddim_uniform"
:
sigmas
=
ddim_scheduler
(
self
.
model_wrap
,
steps
)
sigmas
=
ddim_scheduler
(
self
.
model_wrap
,
steps
)
elif
self
.
scheduler
==
"sgm_uniform"
:
sigmas
=
sgm_scheduler
(
self
.
model_wrap
,
steps
)
else
:
else
:
print
(
"error invalid scheduler"
,
self
.
scheduler
)
print
(
"error invalid scheduler"
,
self
.
scheduler
)
...
...
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