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
0aa667ed
Commit
0aa667ed
authored
Apr 30, 2023
by
comfyanonymous
Browse files
Fix ConditioningAverage.
parent
29c8f1a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
nodes.py
nodes.py
+17
-8
No files found.
nodes.py
View file @
0aa667ed
...
@@ -62,21 +62,30 @@ class ConditioningCombine:
...
@@ -62,21 +62,30 @@ class ConditioningCombine:
class
ConditioningAverage
:
class
ConditioningAverage
:
@
classmethod
@
classmethod
def
INPUT_TYPES
(
s
):
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"conditioning_
from
"
:
(
"CONDITIONING"
,
),
"conditioning_
to
"
:
(
"CONDITIONING"
,
),
return
{
"required"
:
{
"conditioning_
to
"
:
(
"CONDITIONING"
,
),
"conditioning_
from
"
:
(
"CONDITIONING"
,
),
"conditioning_
from
_strength"
:
(
"FLOAT"
,
{
"default"
:
1.0
,
"min"
:
0.0
,
"max"
:
1.0
,
"step"
:
0.1
})
"conditioning_
to
_strength"
:
(
"FLOAT"
,
{
"default"
:
1.0
,
"min"
:
0.0
,
"max"
:
1.0
,
"step"
:
0.
0
1
})
}}
}}
RETURN_TYPES
=
(
"CONDITIONING"
,)
RETURN_TYPES
=
(
"CONDITIONING"
,)
FUNCTION
=
"addWeighted"
FUNCTION
=
"addWeighted"
CATEGORY
=
"conditioning"
CATEGORY
=
"conditioning"
def
addWeighted
(
self
,
conditioning_from
,
conditioning_to
,
conditioning_from_strength
):
def
addWeighted
(
self
,
conditioning_to
,
conditioning_from
,
conditioning_to
_strength
):
out
=
[]
out
=
[]
for
i
in
range
(
min
(
len
(
conditioning_from
),
len
(
conditioning_to
))):
t0
=
conditioning_from
[
i
]
if
len
(
conditioning_from
)
>
1
:
t1
=
conditioning_to
[
i
]
print
(
"Warning: ConditioningAverage conditioning_from contains more than 1 cond, only the first one will actually be applied to conditioning_to."
)
tw
=
torch
.
mul
(
t0
[
0
],(
1
-
conditioning_from_strength
))
+
torch
.
mul
(
t1
[
0
],
conditioning_from_strength
)
n
=
[
tw
,
t0
[
1
].
copy
()]
cond_from
=
conditioning_from
[
0
][
0
]
for
i
in
range
(
len
(
conditioning_to
)):
t1
=
conditioning_to
[
i
][
0
]
t0
=
cond_from
[:,:
t1
.
shape
[
1
]]
if
t0
.
shape
[
1
]
<
t1
.
shape
[
1
]:
t0
=
torch
.
cat
([
t0
]
+
[
torch
.
zeros
((
1
,
(
t1
.
shape
[
1
]
-
t0
.
shape
[
1
]),
t1
.
shape
[
2
]))],
dim
=
1
)
tw
=
torch
.
mul
(
t1
,
conditioning_to_strength
)
+
torch
.
mul
(
t0
,
(
1.0
-
conditioning_to_strength
))
n
=
[
tw
,
conditioning_to
[
i
][
1
].
copy
()]
out
.
append
(
n
)
out
.
append
(
n
)
return
(
out
,
)
return
(
out
,
)
...
...
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