mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-14 06:03:29 +08:00
Merge ed0c0d1c26b8a935a8625e5b198f4f27b173e264 into c8d2117f02bcad6d8316ffd8273bdc27adf83b44
This commit is contained in:
commit
2701e9df15
@ -119,10 +119,24 @@ class PorterDuffImageComposite:
|
||||
CATEGORY = "mask/compositing"
|
||||
|
||||
def composite(self, source: torch.Tensor, source_alpha: torch.Tensor, destination: torch.Tensor, destination_alpha: torch.Tensor, mode):
|
||||
batch_size = min(len(source), len(source_alpha), len(destination), len(destination_alpha))
|
||||
batch_size = min(len(source), len(destination))
|
||||
if batch_size == 1:
|
||||
if len(source) != 1:
|
||||
batch_size = len(source)
|
||||
elif len(destination) != 1:
|
||||
batch_size = len(destination)
|
||||
out_images = []
|
||||
out_alphas = []
|
||||
|
||||
if batch_size != 1:
|
||||
if len(source) == 1:
|
||||
source = source.repeat(batch_size, 1, 1, 1)
|
||||
if len(destination) == 1:
|
||||
destination = destination.repeat(batch_size, 1, 1, 1)
|
||||
if len(source_alpha) == 1:
|
||||
source_alpha = source_alpha.repeat(batch_size, 1, 1)
|
||||
if len(destination_alpha) == 1:
|
||||
destination_alpha = destination_alpha.repeat(batch_size, 1, 1)
|
||||
for i in range(batch_size):
|
||||
src_image = source[i]
|
||||
dst_image = destination[i]
|
||||
@ -192,6 +206,8 @@ class JoinImageWithAlpha:
|
||||
batch_size = min(len(image), len(alpha))
|
||||
out_images = []
|
||||
|
||||
if len(alpha) == 1 and batch_size != 1:
|
||||
alpha = alpha.repeat(batch_size, 1, 1, 1)
|
||||
alpha = 1.0 - resize_mask(alpha, image.shape[1:])
|
||||
for i in range(batch_size):
|
||||
out_images.append(torch.cat((image[i][:,:,:3], alpha[i].unsqueeze(2)), dim=2))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user