mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 05:22:34 +08:00
Use torch.nn.functional.pad
This commit is contained in:
parent
8e82f219dd
commit
6c6d05233c
4
nodes.py
4
nodes.py
@ -1854,9 +1854,9 @@ 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]:
|
||||||
if image1.shape[-1] > image2.shape[-1]:
|
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)
|
image2 = torch.nn.functional.pad(image2, (0,1), mode='constant', value=1.0)
|
||||||
else:
|
else:
|
||||||
image1 = torch.cat((image1, torch.ones((image1.shape[0], image1.shape[1], image1.shape[2], 1))), dim=-1)
|
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…
Reference in New Issue
Block a user