When one Batch Image input has alpha and one does not, add empty alpha channel

This commit is contained in:
Jedrzej Kosinski 2025-11-20 14:19:17 -08:00
parent f5e66d5e47
commit 8e82f219dd

View File

@ -1853,9 +1853,10 @@ class ImageBatch:
def batch(self, image1, image2):
if image1.shape[-1] != image2.shape[-1]:
channels = min(image1.shape[-1], image2.shape[-1])
image1 = image1[..., :channels]
image2 = image2[..., :channels]
if image1.shape[-1] > image2.shape[-1]:
image2 = torch.cat((image2, torch.ones((image2.shape[0], image2.shape[1], image2.shape[2], 1))), dim=-1)
else:
image1 = torch.cat((image1, torch.ones((image1.shape[0], image1.shape[1], image1.shape[2], 1))), dim=-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)
s = torch.cat((image1, image2), dim=0)