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
d7121938
Commit
d7121938
authored
Aug 01, 2023
by
FuamiCake
Browse files
Add LatentBlend node, allowing for blending between two Latent inputs.
parent
eb5191f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
nodes.py
nodes.py
+44
-0
No files found.
nodes.py
View file @
d7121938
...
@@ -1055,6 +1055,48 @@ class LatentComposite:
...
@@ -1055,6 +1055,48 @@ class LatentComposite:
samples_out
[
"samples"
]
=
s
samples_out
[
"samples"
]
=
s
return
(
samples_out
,)
return
(
samples_out
,)
class
LatentBlend
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"samples_a"
:
(
"LATENT"
,),
"samples_b"
:
(
"LATENT"
,),
"blend_factor"
:
(
"FLOAT"
,
{
"default"
:
0.5
,
"min"
:
0
,
"max"
:
1
,
"step"
:
0.01
}),
"blend_mode"
:
([
"normal"
],),
}}
RETURN_TYPES
=
(
"LATENT"
,)
FUNCTION
=
"blend"
CATEGORY
=
"_for_testing"
def
blend
(
self
,
samples_a
,
samples_b
,
blend_factor
:
float
,
blend_mode
:
str
):
samples_out
=
samples_a
.
copy
()
samples_a
=
samples_a
[
"samples"
]
samples_b
=
samples_b
[
"samples"
]
if
samples_a
.
shape
!=
samples_b
.
shape
:
samples_b
.
permute
(
0
,
3
,
1
,
2
)
samples_b
=
comfy
.
utils
.
common_upscale
(
samples_b
,
samples_a
.
shape
[
3
],
samples_a
.
shape
[
2
],
'bicubic'
,
crop
=
'center'
)
samples_b
.
permute
(
0
,
2
,
3
,
1
)
samples_blended
=
self
.
blend_mode
(
samples_a
,
samples_b
,
blend_mode
)
samples_blended
=
samples_a
*
(
1
-
blend_factor
)
+
samples_blended
*
blend_factor
samples_out
[
"samples"
]
=
samples_blended
return
(
samples_out
,)
def
blend_mode
(
self
,
img1
,
img2
,
mode
):
if
mode
==
"normal"
:
return
img2
else
:
raise
ValueError
(
f
"Unsupported blend mode:
{
mode
}
"
)
class
LatentCrop
:
class
LatentCrop
:
@
classmethod
@
classmethod
def
INPUT_TYPES
(
s
):
def
INPUT_TYPES
(
s
):
...
@@ -1501,6 +1543,7 @@ NODE_CLASS_MAPPINGS = {
...
@@ -1501,6 +1543,7 @@ NODE_CLASS_MAPPINGS = {
"KSamplerAdvanced"
:
KSamplerAdvanced
,
"KSamplerAdvanced"
:
KSamplerAdvanced
,
"SetLatentNoiseMask"
:
SetLatentNoiseMask
,
"SetLatentNoiseMask"
:
SetLatentNoiseMask
,
"LatentComposite"
:
LatentComposite
,
"LatentComposite"
:
LatentComposite
,
"LatentBlend"
:
LatentBlend
,
"LatentRotate"
:
LatentRotate
,
"LatentRotate"
:
LatentRotate
,
"LatentFlip"
:
LatentFlip
,
"LatentFlip"
:
LatentFlip
,
"LatentCrop"
:
LatentCrop
,
"LatentCrop"
:
LatentCrop
,
...
@@ -1572,6 +1615,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
...
@@ -1572,6 +1615,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"LatentUpscale"
:
"Upscale Latent"
,
"LatentUpscale"
:
"Upscale Latent"
,
"LatentUpscaleBy"
:
"Upscale Latent By"
,
"LatentUpscaleBy"
:
"Upscale Latent By"
,
"LatentComposite"
:
"Latent Composite"
,
"LatentComposite"
:
"Latent Composite"
,
"LatentBlend"
:
"Latent Blend"
,
"LatentFromBatch"
:
"Latent From Batch"
,
"LatentFromBatch"
:
"Latent From Batch"
,
"RepeatLatentBatch"
:
"Repeat Latent Batch"
,
"RepeatLatentBatch"
:
"Repeat Latent Batch"
,
# Image
# 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