mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2025-12-09 05:54:24 +08:00
Make Batch Images node add alpha channel when one of the inputs has it (#10816)
* When one Batch Image input has alpha and one does not, add empty alpha channel * Use torch.nn.functional.pad
This commit is contained in:
parent
f5e66d5e47
commit
9e00ce5b76
7
nodes.py
7
nodes.py
@ -1853,9 +1853,10 @@ class ImageBatch:
|
|||||||
|
|
||||||
def batch(self, image1, image2):
|
def batch(self, image1, image2):
|
||||||
if image1.shape[-1] != image2.shape[-1]:
|
if image1.shape[-1] != image2.shape[-1]:
|
||||||
channels = min(image1.shape[-1], image2.shape[-1])
|
if image1.shape[-1] > image2.shape[-1]:
|
||||||
image1 = image1[..., :channels]
|
image2 = torch.nn.functional.pad(image2, (0,1), mode='constant', value=1.0)
|
||||||
image2 = image2[..., :channels]
|
else:
|
||||||
|
image1 = torch.nn.functional.pad(image1, (0,1), mode='constant', value=1.0)
|
||||||
if image1.shape[1:] != image2.shape[1:]:
|
if image1.shape[1:] != image2.shape[1:]:
|
||||||
image2 = comfy.utils.common_upscale(image2.movedim(-1,1), image1.shape[2], image1.shape[1], "bilinear", "center").movedim(1,-1)
|
image2 = comfy.utils.common_upscale(image2.movedim(-1,1), image1.shape[2], image1.shape[1], "bilinear", "center").movedim(1,-1)
|
||||||
s = torch.cat((image1, image2), dim=0)
|
s = torch.cat((image1, image2), dim=0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user