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
d826a097
"docs/vscode:/vscode.git/clone" did not exist on "78b87dc25aa3cb5eab282354d9b001b90a75cca4"
Commit
d826a097
authored
Feb 27, 2023
by
comfyanonymous
Browse files
Outpainting actually works now.
parent
75fa1625
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
nodes.py
nodes.py
+7
-4
No files found.
nodes.py
View file @
d826a097
...
@@ -157,20 +157,23 @@ class VAEEncodeForInpaint:
...
@@ -157,20 +157,23 @@ 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
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
]
#
shave off
a few pixels to keep things seamless
#
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
((
1.0
-
mask
.
round
())[
None
],
kernel_tensor
,
padding
=
3
),
0
,
1
)
mask_erosion
=
torch
.
clamp
(
torch
.
nn
.
functional
.
conv2d
((
mask
.
round
())[
None
],
kernel_tensor
,
padding
=
3
),
0
,
1
)
m
=
(
1.0
-
mask
.
round
())
for
i
in
range
(
3
):
for
i
in
range
(
3
):
pixels
[:,:,:,
i
]
-=
0.5
pixels
[:,:,:,
i
]
-=
0.5
pixels
[:,:,:,
i
]
*=
m
ask_erosion
[
0
][:
x
,:
y
].
round
()
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
},
)
return
({
"samples"
:
t
,
"noise_mask"
:
(
mask
_erosion
[
0
][:
x
,:
y
].
round
())
},
)
class
CheckpointLoader
:
class
CheckpointLoader
:
models_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"models"
)
models_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"models"
)
...
...
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