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
00646b08
Commit
00646b08
authored
May 27, 2023
by
space-nuko
Browse files
Bitwise operations for masks
parent
91449472
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
comfy_extras/nodes_mask.py
comfy_extras/nodes_mask.py
+7
-1
No files found.
comfy_extras/nodes_mask.py
View file @
00646b08
...
...
@@ -167,7 +167,7 @@ class MaskComposite:
"source"
:
(
"MASK"
,),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"operation"
:
([
"multiply"
,
"add"
,
"subtract"
],),
"operation"
:
([
"multiply"
,
"add"
,
"subtract"
,
"and"
,
"or"
,
"xor"
],),
}
}
...
...
@@ -193,6 +193,12 @@ class MaskComposite:
output
[
top
:
bottom
,
left
:
right
]
=
destination_portion
+
source_portion
elif
operation
==
"subtract"
:
output
[
top
:
bottom
,
left
:
right
]
=
destination_portion
-
source_portion
elif
operation
==
"and"
:
output
[
top
:
bottom
,
left
:
right
]
=
torch
.
bitwise_and
(
destination_portion
.
bool
(),
source_portion
.
bool
()).
float
()
elif
operation
==
"or"
:
output
[
top
:
bottom
,
left
:
right
]
=
torch
.
bitwise_or
(
destination_portion
.
bool
(),
source_portion
.
bool
()).
float
()
elif
operation
==
"xor"
:
output
[
top
:
bottom
,
left
:
right
]
=
torch
.
bitwise_xor
(
destination_portion
.
bool
(),
source_portion
.
bool
()).
float
()
output
=
torch
.
clamp
(
output
,
0.0
,
1.0
)
...
...
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