mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 01:27:01 +08:00
Rewrite addWeighted to use torch.mul iteratively.
This commit is contained in:
parent
099fb5184a
commit
fff14743d0
18
nodes.py
18
nodes.py
@ -71,16 +71,14 @@ class ConditioningAverage :
|
|||||||
CATEGORY = "conditioning"
|
CATEGORY = "conditioning"
|
||||||
|
|
||||||
def addWeighted(self, conditioning_from, conditioning_to, conditioning_from_strength):
|
def addWeighted(self, conditioning_from, conditioning_to, conditioning_from_strength):
|
||||||
conditioning_to_strength = (1-conditioning_from_strength)
|
out = []
|
||||||
conditioning_from_tensor = conditioning_from[0][0]
|
for i in range(min(len(conditioning_from),len(conditioning_to))):
|
||||||
conditioning_to_tensor = conditioning_to[0][0]
|
t0 = conditioning_from[i]
|
||||||
output = conditioning_from
|
t1 = conditioning_to[i]
|
||||||
if conditioning_from_tensor.shape[0] > conditioning_to_tensor.shape[1]:
|
tw = torch.mul(t0[0],(1-conditioning_from_strength)) + torch.mul(t1[0],conditioning_from_strength)
|
||||||
conditioning_to_tensor = torch.cat((conditioning_to_tensor, torch.zeros((1, conditioning_from_tensor.shape[1] - conditioning_to_tensor.shape[1], conditioning_from_tensor.shape[1].value))), dim=1)
|
n = [tw, t0[1].copy()]
|
||||||
elif conditioning_to_tensor.shape[1] > conditioning_from_tensor.shape[1]:
|
out.append(n)
|
||||||
conditioning_from_tensor = torch.cat((conditioning_from_tensor, torch.zeros((1, conditioning_to_tensor.shape[1] - conditioning_from_tensor.shape[1], conditioning_to_tensor.shape[1].value))), dim=1)
|
return (out, )
|
||||||
output[0][0] = ((conditioning_from_tensor * conditioning_from_strength) + (conditioning_to_tensor * conditioning_to_strength))
|
|
||||||
return (output, )
|
|
||||||
|
|
||||||
class ConditioningSetArea:
|
class ConditioningSetArea:
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user