From 05ad64d22c0c51bf3ccbefcb313fb83c5681a174 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 12 Feb 2023 13:01:52 -0500 Subject: [PATCH 1/2] Add a feather option to the latent composite node. --- nodes.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 12f4b6391e4..aaa4f87a3af 100644 --- a/nodes.py +++ b/nodes.py @@ -301,17 +301,35 @@ def INPUT_TYPES(s): "samples_from": ("LATENT",), "x": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}), "y": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}), + "feather": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}), }} RETURN_TYPES = ("LATENT",) FUNCTION = "composite" CATEGORY = "latent" - def composite(self, samples_to, samples_from, x, y, composite_method="normal"): + def composite(self, samples_to, samples_from, x, y, composite_method="normal", feather=0): x = x // 8 y = y // 8 + feather = feather // 8 s = samples_to.clone() - s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x] + if feather == 0: + s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x] + else: + s_from = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x] + mask = torch.ones_like(s_from) + for t in range(feather): + if y != 0: + mask[:,:,t:1+t,:] *= ((1.0/feather) * (t + 1)) + + if y + samples_from.shape[2] < samples_to.shape[2]: + mask[:,:,mask.shape[2] -1 -t: mask.shape[2]-t,:] *= ((1.0/feather) * (t + 1)) + if x != 0: + mask[:,:,:,t:1+t] *= ((1.0/feather) * (t + 1)) + if x + samples_from.shape[3] < samples_to.shape[3]: + mask[:,:,:,mask.shape[3]- 1 - t: mask.shape[3]- t] *= ((1.0/feather) * (t + 1)) + rev_mask = torch.ones_like(mask) - mask + s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x] * mask + s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] * rev_mask return (s,) class LatentCrop: From 3fd6b7027cac4f29a57c84412c7c01bff6896adc Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 12 Feb 2023 13:29:34 -0500 Subject: [PATCH 2/2] Support dark mode in GUI. --- webshit/index.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/webshit/index.html b/webshit/index.html index 683d9648085..4fb739882c7 100644 --- a/webshit/index.html +++ b/webshit/index.html @@ -3,6 +3,20 @@ +