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
4c01386c
Unverified
Commit
4c01386c
authored
Mar 25, 2023
by
Guo Y.K
Browse files
nodes: ImagePadForOutpaint: fix feathering, ignore edges not expanded
parent
4580f3e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
21 deletions
+26
-21
nodes.py
nodes.py
+26
-21
No files found.
nodes.py
View file @
4c01386c
import
math
import
torch
import
torch
import
os
import
os
...
@@ -942,28 +944,31 @@ class ImagePadForOutpaint:
...
@@ -942,28 +944,31 @@ class ImagePadForOutpaint:
dtype
=
torch
.
float32
,
dtype
=
torch
.
float32
,
)
)
if
feathering
>
0
and
feathering
*
2
<
d2
and
feathering
*
2
<
d3
:
t
=
torch
.
zeros
(
# distances to border
(
d2
,
d3
),
mi
,
mj
=
torch
.
meshgrid
(
dtype
=
torch
.
float32
torch
.
arange
(
d2
,
dtype
=
torch
.
float32
),
torch
.
arange
(
d3
,
dtype
=
torch
.
float32
),
indexing
=
'ij'
,
)
distances
=
torch
.
minimum
(
torch
.
minimum
(
mi
,
mj
),
torch
.
minimum
(
d2
-
1
-
mi
,
d3
-
1
-
mj
),
)
)
# convert distances to square falloff from 1 to 0
t
=
(
feathering
-
distances
)
/
feathering
if
feathering
>
0
and
feathering
*
2
<
d2
and
feathering
*
2
<
d3
:
t
.
clamp_
(
min
=
0
)
t
.
square_
()
for
i
in
range
(
d2
):
for
j
in
range
(
d3
):
dt
=
i
if
top
!=
0
else
d2
db
=
d2
-
i
if
bottom
!=
0
else
d2
dl
=
j
if
left
!=
0
else
d3
dr
=
d3
-
j
if
right
!=
0
else
d3
d
=
min
(
dt
,
db
,
dl
,
dr
)
if
d
>=
feathering
:
continue
v
=
(
feathering
-
d
)
/
feathering
t
[
i
,
j
]
=
v
*
v
mask
[
top
:
top
+
d2
,
left
:
left
+
d3
]
=
t
mask
[
top
:
top
+
d2
,
left
:
left
+
d3
]
=
t
else
:
mask
[
top
:
top
+
d2
,
left
:
left
+
d3
]
=
torch
.
zeros
(
(
d2
,
d3
),
dtype
=
torch
.
float32
,
)
return
(
new_image
,
mask
)
return
(
new_image
,
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