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
4580f3e6
Unverified
Commit
4580f3e6
authored
Mar 24, 2023
by
Guo Y.K
Browse files
nodes: add feathering to to ImagePadForOutpaint
parent
3ebf7452
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
+26
-5
nodes.py
nodes.py
+26
-5
No files found.
nodes.py
View file @
4580f3e6
...
@@ -919,6 +919,7 @@ class ImagePadForOutpaint:
...
@@ -919,6 +919,7 @@ class ImagePadForOutpaint:
"top"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"top"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"right"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"right"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"bottom"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"bottom"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"feathering"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
1
}),
}
}
}
}
...
@@ -927,7 +928,7 @@ class ImagePadForOutpaint:
...
@@ -927,7 +928,7 @@ class ImagePadForOutpaint:
CATEGORY
=
"image"
CATEGORY
=
"image"
def
expand_image
(
self
,
image
,
left
,
top
,
right
,
bottom
):
def
expand_image
(
self
,
image
,
left
,
top
,
right
,
bottom
,
feathering
):
d1
,
d2
,
d3
,
d4
=
image
.
size
()
d1
,
d2
,
d3
,
d4
=
image
.
size
()
new_image
=
torch
.
zeros
(
new_image
=
torch
.
zeros
(
...
@@ -940,10 +941,30 @@ class ImagePadForOutpaint:
...
@@ -940,10 +941,30 @@ class ImagePadForOutpaint:
(
d2
+
top
+
bottom
,
d3
+
left
+
right
),
(
d2
+
top
+
bottom
,
d3
+
left
+
right
),
dtype
=
torch
.
float32
,
dtype
=
torch
.
float32
,
)
)
mask
[
top
:
top
+
d2
,
left
:
left
+
d3
]
=
torch
.
zeros
(
(
d2
,
d3
),
if
feathering
>
0
and
feathering
*
2
<
d2
and
feathering
*
2
<
d3
:
dtype
=
torch
.
float32
,
# distances to border
)
mi
,
mj
=
torch
.
meshgrid
(
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
t
.
clamp_
(
min
=
0
)
t
.
square_
()
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