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
0e763e88
Commit
0e763e88
authored
Oct 04, 2023
by
comfyanonymous
Browse files
JoinImageWithAlpha now works with any mask shape.
parent
9212bea8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
comfy_extras/nodes_compositing.py
comfy_extras/nodes_compositing.py
+3
-0
No files found.
comfy_extras/nodes_compositing.py
View file @
0e763e88
...
...
@@ -3,6 +3,8 @@ import torch
import
comfy.utils
from
enum
import
Enum
def
resize_mask
(
mask
,
shape
):
return
torch
.
nn
.
functional
.
interpolate
(
mask
.
reshape
((
-
1
,
1
,
mask
.
shape
[
-
2
],
mask
.
shape
[
-
1
])),
size
=
(
shape
[
0
],
shape
[
1
]),
mode
=
"bilinear"
).
squeeze
(
1
)
class
PorterDuffMode
(
Enum
):
ADD
=
0
...
...
@@ -178,6 +180,7 @@ class JoinImageWithAlpha:
batch_size
=
min
(
len
(
image
),
len
(
alpha
))
out_images
=
[]
alpha
=
resize_mask
(
alpha
,
image
.
shape
[
1
:])
for
i
in
range
(
batch_size
):
out_images
.
append
(
torch
.
cat
((
image
[
i
][:,:,:
3
],
alpha
[
i
].
unsqueeze
(
2
)),
dim
=
2
))
...
...
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