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
99eb777f
Commit
99eb777f
authored
Mar 09, 2023
by
comfyanonymous
Browse files
Make the LoadImage node output the alpha as a mask.
parent
b94ed02a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
nodes.py
nodes.py
+7
-2
No files found.
nodes.py
View file @
99eb777f
...
@@ -815,7 +815,7 @@ class LoadImage:
...
@@ -815,7 +815,7 @@ class LoadImage:
CATEGORY
=
"image"
CATEGORY
=
"image"
RETURN_TYPES
=
(
"IMAGE"
,)
RETURN_TYPES
=
(
"IMAGE"
,
"MASK"
)
FUNCTION
=
"load_image"
FUNCTION
=
"load_image"
def
load_image
(
self
,
image
):
def
load_image
(
self
,
image
):
image_path
=
os
.
path
.
join
(
self
.
input_dir
,
image
)
image_path
=
os
.
path
.
join
(
self
.
input_dir
,
image
)
...
@@ -823,7 +823,12 @@ class LoadImage:
...
@@ -823,7 +823,12 @@ class LoadImage:
image
=
i
.
convert
(
"RGB"
)
image
=
i
.
convert
(
"RGB"
)
image
=
np
.
array
(
image
).
astype
(
np
.
float32
)
/
255.0
image
=
np
.
array
(
image
).
astype
(
np
.
float32
)
/
255.0
image
=
torch
.
from_numpy
(
image
)[
None
,]
image
=
torch
.
from_numpy
(
image
)[
None
,]
return
(
image
,)
if
'A'
in
i
.
getbands
():
mask
=
np
.
array
(
i
.
getchannel
(
'A'
)).
astype
(
np
.
float32
)
/
255.0
mask
=
1.
-
torch
.
from_numpy
(
mask
)
else
:
mask
=
torch
.
zeros
((
64
,
64
),
dtype
=
torch
.
float32
,
device
=
"cpu"
)
return
(
image
,
mask
)
@
classmethod
@
classmethod
def
IS_CHANGED
(
s
,
image
):
def
IS_CHANGED
(
s
,
image
):
...
...
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