Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

JoinImageWithAlpha now works with any mask shape.

comfyanonymous0e763e880f5e
diff --git a/comfy_extras/nodes_compositing.py b/comfy_extras/nodes_compositing.py
index f8901eca1..68bfce111 100644
--- a/comfy_extras/nodes_compositing.py
+++ b/comfy_extras/nodes_compositing.py
@@ -3,6 +3,8 @@ import torch
import comfy.utils
from enum import Enum
+def resize_mask(mask, shape):
+ return torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(shape[0], shape[1]), mode="bilinear").squeeze(1)
class PorterDuffMode(Enum):
ADD = 0
@@ -178,6 +180,7 @@ class JoinImageWithAlpha:
batch_size = min(len(image), len(alpha))
out_images = []
+ alpha = 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))