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
c7c1f0d0
Commit
c7c1f0d0
authored
Apr 25, 2023
by
comfyanonymous
Browse files
Merge branch 'multiple_inpaint_masks' of
https://github.com/guill/ComfyUI
# Conflicts: # nodes.py
parents
c50208a7
ee030d28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
nodes.py
nodes.py
+9
-5
No files found.
nodes.py
View file @
c7c1f0d0
...
@@ -172,24 +172,28 @@ class VAEEncodeForInpaint:
...
@@ -172,24 +172,28 @@ class VAEEncodeForInpaint:
def
encode
(
self
,
vae
,
pixels
,
mask
):
def
encode
(
self
,
vae
,
pixels
,
mask
):
x
=
(
pixels
.
shape
[
1
]
//
64
)
*
64
x
=
(
pixels
.
shape
[
1
]
//
64
)
*
64
y
=
(
pixels
.
shape
[
2
]
//
64
)
*
64
y
=
(
pixels
.
shape
[
2
]
//
64
)
*
64
mask
=
torch
.
nn
.
functional
.
interpolate
(
mask
[
None
,
None
,],
size
=
(
pixels
.
shape
[
1
],
pixels
.
shape
[
2
]),
mode
=
"bilinear"
)[
0
][
0
]
if
len
(
mask
.
shape
)
<
3
:
mask
=
mask
.
unsqueeze
(
0
).
unsqueeze
(
0
)
elif
len
(
mask
.
shape
)
<
4
:
mask
=
mask
.
unsqueeze
(
1
)
mask
=
torch
.
nn
.
functional
.
interpolate
(
mask
,
size
=
(
pixels
.
shape
[
1
],
pixels
.
shape
[
2
]),
mode
=
"bilinear"
)
pixels
=
pixels
.
clone
()
pixels
=
pixels
.
clone
()
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
pixels
=
pixels
[:,:
x
,:
y
,:]
pixels
=
pixels
[:,:
x
,:
y
,:]
mask
=
mask
[:
x
,:
y
]
mask
=
mask
[:
,:
x
,:
y
,:
]
#grow mask by a few pixels to keep things seamless in latent space
#grow mask by a few pixels to keep things seamless in latent space
kernel_tensor
=
torch
.
ones
((
1
,
1
,
6
,
6
))
kernel_tensor
=
torch
.
ones
((
1
,
1
,
6
,
6
))
mask_erosion
=
torch
.
clamp
(
torch
.
nn
.
functional
.
conv2d
(
(
mask
.
round
()
)[
None
]
,
kernel_tensor
,
padding
=
3
),
0
,
1
)
mask_erosion
=
torch
.
clamp
(
torch
.
nn
.
functional
.
conv2d
(
mask
.
round
(),
kernel_tensor
,
padding
=
3
),
0
,
1
)
m
=
(
1.0
-
mask
.
round
())
m
=
(
1.0
-
mask
.
round
())
.
squeeze
(
1
)
for
i
in
range
(
3
):
for
i
in
range
(
3
):
pixels
[:,:,:,
i
]
-=
0.5
pixels
[:,:,:,
i
]
-=
0.5
pixels
[:,:,:,
i
]
*=
m
pixels
[:,:,:,
i
]
*=
m
pixels
[:,:,:,
i
]
+=
0.5
pixels
[:,:,:,
i
]
+=
0.5
t
=
vae
.
encode
(
pixels
)
t
=
vae
.
encode
(
pixels
)
return
({
"samples"
:
t
,
"noise_mask"
:
(
mask_erosion
[
0
][
:
x
,:
y
].
round
())},
)
return
({
"samples"
:
t
,
"noise_mask"
:
(
mask_erosion
[
:,
:
x
,:
y
,:
].
round
())},
)
class
CheckpointLoader
:
class
CheckpointLoader
:
@
classmethod
@
classmethod
...
...
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