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
e11052af
Commit
e11052af
authored
Jun 19, 2024
by
comfyanonymous
Browse files
Add ipndm sampler.
parent
97ae6ef4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
comfy/k_diffusion/sampling.py
comfy/k_diffusion/sampling.py
+41
-0
comfy/samplers.py
comfy/samplers.py
+2
-1
No files found.
comfy/k_diffusion/sampling.py
View file @
e11052af
...
...
@@ -841,3 +841,44 @@ def sample_heunpp2(model, x, sigmas, extra_args=None, callback=None, disable=Non
d_prime
=
w1
*
d
+
w2
*
d_2
+
w3
*
d_3
x
=
x
+
d_prime
*
dt
return
x
#From https://github.com/zju-pi/diff-sampler/blob/main/diff-solvers-main/solvers.py
#under Apache 2 license
def
sample_ipndm
(
model
,
x
,
sigmas
,
extra_args
=
None
,
callback
=
None
,
disable
=
None
,
max_order
=
4
):
extra_args
=
{}
if
extra_args
is
None
else
extra_args
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
x_next
=
x
buffer_model
=
[]
for
i
in
trange
(
len
(
sigmas
)
-
1
,
disable
=
disable
):
t_cur
=
sigmas
[
i
]
t_next
=
sigmas
[
i
+
1
]
x_cur
=
x_next
denoised
=
model
(
x_cur
,
t_cur
*
s_in
,
**
extra_args
)
if
callback
is
not
None
:
callback
({
'x'
:
x
,
'i'
:
i
,
'sigma'
:
sigmas
[
i
],
'sigma_hat'
:
sigmas
[
i
],
'denoised'
:
denoised
})
d_cur
=
(
x_cur
-
denoised
)
/
t_cur
order
=
min
(
max_order
,
i
+
1
)
if
order
==
1
:
# First Euler step.
x_next
=
x_cur
+
(
t_next
-
t_cur
)
*
d_cur
elif
order
==
2
:
# Use one history point.
x_next
=
x_cur
+
(
t_next
-
t_cur
)
*
(
3
*
d_cur
-
buffer_model
[
-
1
])
/
2
elif
order
==
3
:
# Use two history points.
x_next
=
x_cur
+
(
t_next
-
t_cur
)
*
(
23
*
d_cur
-
16
*
buffer_model
[
-
1
]
+
5
*
buffer_model
[
-
2
])
/
12
elif
order
==
4
:
# Use three history points.
x_next
=
x_cur
+
(
t_next
-
t_cur
)
*
(
55
*
d_cur
-
59
*
buffer_model
[
-
1
]
+
37
*
buffer_model
[
-
2
]
-
9
*
buffer_model
[
-
3
])
/
24
if
len
(
buffer_model
)
==
max_order
-
1
:
for
k
in
range
(
max_order
-
2
):
buffer_model
[
k
]
=
buffer_model
[
k
+
1
]
buffer_model
[
-
1
]
=
d_cur
else
:
buffer_model
.
append
(
d_cur
)
return
x_next
comfy/samplers.py
View file @
e11052af
...
...
@@ -539,7 +539,8 @@ class Sampler:
KSAMPLER_NAMES
=
[
"euler"
,
"euler_ancestral"
,
"heun"
,
"heunpp2"
,
"dpm_2"
,
"dpm_2_ancestral"
,
"lms"
,
"dpm_fast"
,
"dpm_adaptive"
,
"dpmpp_2s_ancestral"
,
"dpmpp_sde"
,
"dpmpp_sde_gpu"
,
"dpmpp_2m"
,
"dpmpp_2m_sde"
,
"dpmpp_2m_sde_gpu"
,
"dpmpp_3m_sde"
,
"dpmpp_3m_sde_gpu"
,
"ddpm"
,
"lcm"
]
"dpmpp_2m"
,
"dpmpp_2m_sde"
,
"dpmpp_2m_sde_gpu"
,
"dpmpp_3m_sde"
,
"dpmpp_3m_sde_gpu"
,
"ddpm"
,
"lcm"
,
"ipndm"
]
class
KSAMPLER
(
Sampler
):
def
__init__
(
self
,
sampler_function
,
extra_options
=
{},
inpaint_options
=
{}):
...
...
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