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
071011ae
Commit
071011ae
authored
Apr 29, 2023
by
comfyanonymous
Browse files
Mask strength should be separate from area strength.
parent
870fae62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
comfy/samplers.py
comfy/samplers.py
+4
-1
nodes.py
nodes.py
+2
-4
No files found.
comfy/samplers.py
View file @
071011ae
...
@@ -26,10 +26,13 @@ def sampling_function(model_function, x, timestep, uncond, cond, cond_scale, con
...
@@ -26,10 +26,13 @@ def sampling_function(model_function, x, timestep, uncond, cond, cond_scale, con
if
'mask'
in
cond
[
1
]:
if
'mask'
in
cond
[
1
]:
# Scale the mask to the size of the input
# Scale the mask to the size of the input
# The mask should have been resized as we began the sampling process
# The mask should have been resized as we began the sampling process
mask_strength
=
1.0
if
"mask_strength"
in
cond
[
1
]:
mask_strength
=
cond
[
1
][
"mask_strength"
]
mask
=
cond
[
1
][
'mask'
]
mask
=
cond
[
1
][
'mask'
]
assert
(
mask
.
shape
[
1
]
==
x_in
.
shape
[
2
])
assert
(
mask
.
shape
[
1
]
==
x_in
.
shape
[
2
])
assert
(
mask
.
shape
[
2
]
==
x_in
.
shape
[
3
])
assert
(
mask
.
shape
[
2
]
==
x_in
.
shape
[
3
])
mask
=
mask
[:,
area
[
2
]:
area
[
0
]
+
area
[
2
],
area
[
3
]:
area
[
1
]
+
area
[
3
]]
mask
=
mask
[:,
area
[
2
]:
area
[
0
]
+
area
[
2
],
area
[
3
]:
area
[
1
]
+
area
[
3
]]
*
mask_strength
mask
=
mask
.
unsqueeze
(
1
).
repeat
(
input_x
.
shape
[
0
]
//
mask
.
shape
[
0
],
input_x
.
shape
[
1
],
1
,
1
)
mask
=
mask
.
unsqueeze
(
1
).
repeat
(
input_x
.
shape
[
0
]
//
mask
.
shape
[
0
],
input_x
.
shape
[
1
],
1
,
1
)
else
:
else
:
mask
=
torch
.
ones_like
(
input_x
)
mask
=
torch
.
ones_like
(
input_x
)
...
...
nodes.py
View file @
071011ae
...
@@ -98,7 +98,7 @@ class ConditioningSetMask:
...
@@ -98,7 +98,7 @@ class ConditioningSetMask:
CATEGORY
=
"conditioning"
CATEGORY
=
"conditioning"
def
append
(
self
,
conditioning
,
mask
,
set_area_to_bounds
,
strength
,
min_sigma
=
0.0
,
max_sigma
=
99.0
):
def
append
(
self
,
conditioning
,
mask
,
set_area_to_bounds
,
strength
):
c
=
[]
c
=
[]
if
len
(
mask
.
shape
)
<
3
:
if
len
(
mask
.
shape
)
<
3
:
mask
=
mask
.
unsqueeze
(
0
)
mask
=
mask
.
unsqueeze
(
0
)
...
@@ -107,9 +107,7 @@ class ConditioningSetMask:
...
@@ -107,9 +107,7 @@ class ConditioningSetMask:
_
,
h
,
w
=
mask
.
shape
_
,
h
,
w
=
mask
.
shape
n
[
1
][
'mask'
]
=
mask
n
[
1
][
'mask'
]
=
mask
n
[
1
][
'set_area_to_bounds'
]
=
set_area_to_bounds
n
[
1
][
'set_area_to_bounds'
]
=
set_area_to_bounds
n
[
1
][
'strength'
]
=
strength
n
[
1
][
'mask_strength'
]
=
strength
n
[
1
][
'min_sigma'
]
=
min_sigma
n
[
1
][
'max_sigma'
]
=
max_sigma
c
.
append
(
n
)
c
.
append
(
n
)
return
(
c
,
)
return
(
c
,
)
...
...
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