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
35a2c790
Unverified
Commit
35a2c790
authored
Apr 14, 2023
by
comfyanonymous
Committed by
GitHub
Apr 14, 2023
Browse files
Update comfy_extras/nodes_mask.py
Co-authored-by:
missionfloyd
<
missionfloyd@users.noreply.github.com
>
parent
022a9f27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
comfy_extras/nodes_mask.py
comfy_extras/nodes_mask.py
+6
-3
No files found.
comfy_extras/nodes_mask.py
View file @
35a2c790
...
@@ -9,8 +9,8 @@ class LatentCompositeMasked:
...
@@ -9,8 +9,8 @@ class LatentCompositeMasked:
"required"
:
{
"required"
:
{
"destination"
:
(
"LATENT"
,),
"destination"
:
(
"LATENT"
,),
"source"
:
(
"LATENT"
,),
"source"
:
(
"LATENT"
,),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
-
MAX_RESOLUTION
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
-
MAX_RESOLUTION
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
},
},
"optional"
:
{
"optional"
:
{
"mask"
:
(
"MASK"
,),
"mask"
:
(
"MASK"
,),
...
@@ -26,6 +26,9 @@ class LatentCompositeMasked:
...
@@ -26,6 +26,9 @@ class LatentCompositeMasked:
destination
=
destination
[
"samples"
].
clone
()
destination
=
destination
[
"samples"
].
clone
()
source
=
source
[
"samples"
]
source
=
source
[
"samples"
]
x
=
max
(
-
source
.
shape
[
3
]
*
8
,
min
(
x
,
destination
.
shape
[
3
]
*
8
))
y
=
max
(
-
source
.
shape
[
2
]
*
8
,
min
(
y
,
destination
.
shape
[
2
]
*
8
))
left
,
top
=
(
x
//
8
,
y
//
8
)
left
,
top
=
(
x
//
8
,
y
//
8
)
right
,
bottom
=
(
left
+
source
.
shape
[
3
],
top
+
source
.
shape
[
2
],)
right
,
bottom
=
(
left
+
source
.
shape
[
3
],
top
+
source
.
shape
[
2
],)
...
@@ -40,7 +43,7 @@ class LatentCompositeMasked:
...
@@ -40,7 +43,7 @@ class LatentCompositeMasked:
# calculate the bounds of the source that will be overlapping the destination
# calculate the bounds of the source that will be overlapping the destination
# this prevents the source trying to overwrite latent pixels that are out of bounds
# this prevents the source trying to overwrite latent pixels that are out of bounds
# of the destination
# of the destination
visible_width
,
visible_height
=
(
destination
.
shape
[
3
]
-
left
,
destination
.
shape
[
2
]
-
top
,)
visible_width
,
visible_height
=
(
destination
.
shape
[
3
]
-
left
+
min
(
0
,
x
)
,
destination
.
shape
[
2
]
-
top
+
min
(
0
,
y
)
,)
mask
=
mask
[:,
:,
:
visible_height
,
:
visible_width
]
mask
=
mask
[:,
:,
:
visible_height
,
:
visible_width
]
inverse_mask
=
torch
.
ones_like
(
mask
)
-
mask
inverse_mask
=
torch
.
ones_like
(
mask
)
-
mask
...
...
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