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
488de0b4
Commit
488de0b4
authored
Nov 27, 2023
by
comfyanonymous
Browse files
ModelSamplingDiscreteLCM -> ModelSamplingDiscreteDistilled
parent
13fdee6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
comfy_extras/nodes_model_advanced.py
comfy_extras/nodes_model_advanced.py
+8
-7
No files found.
comfy_extras/nodes_model_advanced.py
View file @
488de0b4
...
...
@@ -17,7 +17,9 @@ class LCM(comfy.model_sampling.EPS):
return
c_out
*
x0
+
c_skip
*
model_input
class
ModelSamplingDiscreteLCM
(
torch
.
nn
.
Module
):
class
ModelSamplingDiscreteDistilled
(
torch
.
nn
.
Module
):
original_timesteps
=
50
def
__init__
(
self
):
super
().
__init__
()
self
.
sigma_data
=
1.0
...
...
@@ -29,13 +31,12 @@ class ModelSamplingDiscreteLCM(torch.nn.Module):
alphas
=
1.0
-
betas
alphas_cumprod
=
torch
.
cumprod
(
alphas
,
dim
=
0
)
original_timesteps
=
50
self
.
skip_steps
=
timesteps
//
original_timesteps
self
.
skip_steps
=
timesteps
//
self
.
original_timesteps
alphas_cumprod_valid
=
torch
.
zeros
((
original_timesteps
),
dtype
=
torch
.
float32
)
for
x
in
range
(
original_timesteps
):
alphas_cumprod_valid
[
original_timesteps
-
1
-
x
]
=
alphas_cumprod
[
timesteps
-
1
-
x
*
self
.
skip_steps
]
alphas_cumprod_valid
=
torch
.
zeros
((
self
.
original_timesteps
),
dtype
=
torch
.
float32
)
for
x
in
range
(
self
.
original_timesteps
):
alphas_cumprod_valid
[
self
.
original_timesteps
-
1
-
x
]
=
alphas_cumprod
[
timesteps
-
1
-
x
*
self
.
skip_steps
]
sigmas
=
((
1
-
alphas_cumprod_valid
)
/
alphas_cumprod_valid
)
**
0.5
self
.
set_sigmas
(
sigmas
)
...
...
@@ -116,7 +117,7 @@ class ModelSamplingDiscrete:
sampling_type
=
comfy
.
model_sampling
.
V_PREDICTION
elif
sampling
==
"lcm"
:
sampling_type
=
LCM
sampling_base
=
ModelSamplingDiscrete
LCM
sampling_base
=
ModelSamplingDiscrete
Distilled
class
ModelSamplingAdvanced
(
sampling_base
,
sampling_type
):
pass
...
...
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