1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 15:04:50 +08:00

Fix alpha image issue in more nodes.

This commit is contained in:
comfyanonymous
2025-04-02 19:32:34 -04:00
parent 2222cf67fd
commit 3d2e3a6f29
3 changed files with 12 additions and 6 deletions

View File

@@ -44,3 +44,11 @@ def string_to_torch_dtype(string):
return torch.float16
if string == "bf16":
return torch.bfloat16
def image_alpha_fix(destination, source):
if destination.shape[-1] < source.shape[-1]:
source = source[...,:destination.shape[-1]]
elif destination.shape[-1] > source.shape[-1]:
destination = torch.nn.functional.pad(destination, (0, 1))
destination[..., -1] = source[..., -1]
return destination, source