Make LatentBlend more consistent with other nodes.

This commit is contained in:
comfyanonymous 2023-08-04 02:51:28 -04:00
parent 11ad6060fc
commit fa962e86c1

View File

@ -1059,15 +1059,14 @@ class LatentBlend:
@classmethod @classmethod
def INPUT_TYPES(s): def INPUT_TYPES(s):
return {"required": { return {"required": {
"samples_a": ("LATENT",), "samples1": ("LATENT",),
"samples_b": ("LATENT",), "samples2": ("LATENT",),
"blend_factor": ("FLOAT", { "blend_factor": ("FLOAT", {
"default": 0.5, "default": 0.5,
"min": 0, "min": 0,
"max": 1, "max": 1,
"step": 0.01 "step": 0.01
}), }),
"blend_mode": (["normal"],),
}} }}
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
@ -1075,19 +1074,19 @@ class LatentBlend:
CATEGORY = "_for_testing" CATEGORY = "_for_testing"
def blend(self, samples_a, samples_b, blend_factor:float, blend_mode: str): def blend(self, samples1, samples2, blend_factor:float, blend_mode: str="normal"):
samples_out = samples_a.copy() samples_out = samples1.copy()
samples_a = samples_a["samples"] samples1 = samples1["samples"]
samples_b = samples_b["samples"] samples2 = samples2["samples"]
if samples_a.shape != samples_b.shape: if samples1.shape != samples2.shape:
samples_b.permute(0, 3, 1, 2) samples2.permute(0, 3, 1, 2)
samples_b = comfy.utils.common_upscale(samples_b, samples_a.shape[3], samples_a.shape[2], 'bicubic', crop='center') samples2 = comfy.utils.common_upscale(samples2, samples1.shape[3], samples1.shape[2], 'bicubic', crop='center')
samples_b.permute(0, 2, 3, 1) samples2.permute(0, 2, 3, 1)
samples_blended = self.blend_mode(samples_a, samples_b, blend_mode) samples_blended = self.blend_mode(samples1, samples2, blend_mode)
samples_blended = samples_a * (1 - blend_factor) + samples_blended * blend_factor samples_blended = samples1 * blend_factor + samples_blended * (1 - blend_factor)
samples_out["samples"] = samples_blended samples_out["samples"] = samples_blended
return (samples_out,) return (samples_out,)