Skip to content

Commit 9e00ce5

Browse files
authored
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
1 parent f5e66d5 commit 9e00ce5

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

nodes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,9 +1853,10 @@ def INPUT_TYPES(s):
18531853

18541854
def batch(self, image1, image2):
18551855
if image1.shape[-1] != image2.shape[-1]:
1856-
channels = min(image1.shape[-1], image2.shape[-1])
1857-
image1 = image1[..., :channels]
1858-
image2 = image2[..., :channels]
1856+
if image1.shape[-1] > image2.shape[-1]:
1857+
image2 = torch.nn.functional.pad(image2, (0,1), mode='constant', value=1.0)
1858+
else:
1859+
image1 = torch.nn.functional.pad(image1, (0,1), mode='constant', value=1.0)
18591860
if image1.shape[1:] != image2.shape[1:]:
18601861
image2 = comfy.utils.common_upscale(image2.movedim(-1,1), image1.shape[2], image1.shape[1], "bilinear", "center").movedim(1,-1)
18611862
s = torch.cat((image1, image2), dim=0)

0 commit comments

Comments
 (0)