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
c62e8361
Commit
c62e8361
authored
Mar 01, 2024
by
comfyanonymous
Browse files
Move noise scaling to object with sampling math.
parent
cb7c3a29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
comfy/model_sampling.py
comfy/model_sampling.py
+8
-0
comfy/samplers.py
comfy/samplers.py
+1
-7
No files found.
comfy/model_sampling.py
View file @
c62e8361
...
...
@@ -11,6 +11,14 @@ class EPS:
sigma
=
sigma
.
view
(
sigma
.
shape
[:
1
]
+
(
1
,)
*
(
model_output
.
ndim
-
1
))
return
model_input
-
model_output
*
sigma
def
noise_scaling
(
self
,
sigma
,
noise
,
latent_image
,
max_denoise
=
False
):
if
max_denoise
:
noise
=
noise
*
torch
.
sqrt
(
1.0
+
sigma
**
2.0
)
else
:
noise
=
noise
*
sigma
if
latent_image
is
not
None
:
noise
+=
latent_image
return
noise
class
V_PREDICTION
(
EPS
):
def
calculate_denoised
(
self
,
sigma
,
model_output
,
model_input
):
...
...
comfy/samplers.py
View file @
c62e8361
...
...
@@ -534,19 +534,13 @@ class KSAMPLER(Sampler):
else
:
model_k
.
noise
=
noise
if
self
.
max_denoise
(
model_wrap
,
sigmas
):
noise
=
noise
*
torch
.
sqrt
(
1.0
+
sigmas
[
0
]
**
2.0
)
else
:
noise
=
noise
*
sigmas
[
0
]
noise
=
model_wrap
.
inner_model
.
model_sampling
.
noise_scaling
(
sigmas
[
0
],
noise
,
latent_image
,
self
.
max_denoise
(
model_wrap
,
sigmas
))
k_callback
=
None
total_steps
=
len
(
sigmas
)
-
1
if
callback
is
not
None
:
k_callback
=
lambda
x
:
callback
(
x
[
"i"
],
x
[
"denoised"
],
x
[
"x"
],
total_steps
)
if
latent_image
is
not
None
:
noise
+=
latent_image
samples
=
self
.
sampler_function
(
model_k
,
noise
,
sigmas
,
extra_args
=
extra_args
,
callback
=
k_callback
,
disable
=
disable_pbar
,
**
self
.
extra_options
)
return
samples
...
...
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