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
d741e7aa
Commit
d741e7aa
authored
Mar 25, 2023
by
comfyanonymous
Browse files
Merge branch 'feat-add-image-pad-for-outpaint' of
https://github.com/guoyk93/ComfyUI
parents
bfe64dc7
3b873029
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
nodes.py
nodes.py
+64
-0
No files found.
nodes.py
View file @
d741e7aa
...
@@ -908,6 +908,69 @@ class ImageInvert:
...
@@ -908,6 +908,69 @@ class ImageInvert:
return
(
s
,)
return
(
s
,)
class
ImagePadForOutpaint
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"left"
:
(
"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
}),
"bottom"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
64
}),
"feathering"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
4096
,
"step"
:
1
}),
}
}
RETURN_TYPES
=
(
"IMAGE"
,
"MASK"
)
FUNCTION
=
"expand_image"
CATEGORY
=
"image"
def
expand_image
(
self
,
image
,
left
,
top
,
right
,
bottom
,
feathering
):
d1
,
d2
,
d3
,
d4
=
image
.
size
()
new_image
=
torch
.
zeros
(
(
d1
,
d2
+
top
+
bottom
,
d3
+
left
+
right
,
d4
),
dtype
=
torch
.
float32
,
)
new_image
[:,
top
:
top
+
d2
,
left
:
left
+
d3
,
:]
=
image
mask
=
torch
.
ones
(
(
d2
+
top
+
bottom
,
d3
+
left
+
right
),
dtype
=
torch
.
float32
,
)
t
=
torch
.
zeros
(
(
d2
,
d3
),
dtype
=
torch
.
float32
)
if
feathering
>
0
and
feathering
*
2
<
d2
and
feathering
*
2
<
d3
:
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
return
(
new_image
,
mask
)
NODE_CLASS_MAPPINGS
=
{
NODE_CLASS_MAPPINGS
=
{
"KSampler"
:
KSampler
,
"KSampler"
:
KSampler
,
"CheckpointLoader"
:
CheckpointLoader
,
"CheckpointLoader"
:
CheckpointLoader
,
...
@@ -926,6 +989,7 @@ NODE_CLASS_MAPPINGS = {
...
@@ -926,6 +989,7 @@ NODE_CLASS_MAPPINGS = {
"LoadImageMask"
:
LoadImageMask
,
"LoadImageMask"
:
LoadImageMask
,
"ImageScale"
:
ImageScale
,
"ImageScale"
:
ImageScale
,
"ImageInvert"
:
ImageInvert
,
"ImageInvert"
:
ImageInvert
,
"ImagePadForOutpaint"
:
ImagePadForOutpaint
,
"ConditioningCombine"
:
ConditioningCombine
,
"ConditioningCombine"
:
ConditioningCombine
,
"ConditioningSetArea"
:
ConditioningSetArea
,
"ConditioningSetArea"
:
ConditioningSetArea
,
"KSamplerAdvanced"
:
KSamplerAdvanced
,
"KSamplerAdvanced"
:
KSamplerAdvanced
,
...
...
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