From 96b3897f95fcdc55b7e4048cb081e87e4641876a Mon Sep 17 00:00:00 2001 From: yolain Date: Wed, 3 Apr 2024 00:39:02 +0800 Subject: [PATCH] fix:Differential Diffusion with grow_mask_by in kSamplerInpainting --- py/easyNodes.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/py/easyNodes.py b/py/easyNodes.py index 8c8c3c1..37bfb2d 100644 --- a/py/easyNodes.py +++ b/py/easyNodes.py @@ -3889,28 +3889,20 @@ class samplerSimpleInpainting: negative = pipe['negative'] pixels = pipe["images"] if pipe and "images" in pipe else None vae = pipe["vae"] if pipe and "vae" in pipe else None - if 'noise_mask' in latent: + if 'noise_mask' in latent and mask is None: mask = latent['noise_mask'] - - if 'noise_mask' not in latent: + else: if pixels is None: raise Exception("No Images found") if vae is None: raise Exception("No VAE found") latent, = VAEEncodeForInpaint().encode(vae, pixels, mask, grow_mask_by) + mask = latent['noise_mask'] if mask is not None: if additional != "None": - if grow_mask_by == 0: - mask_erosion = mask - else: - kernel_tensor = torch.ones((1, 1, grow_mask_by, grow_mask_by)) - padding = math.ceil((grow_mask_by - 1) / 2) - mask_erosion = torch.clamp(torch.nn.functional.conv2d(mask.round(), kernel_tensor, padding=padding), - 0, - 1) - positive, negative, latent = InpaintModelConditioning().encode(positive, negative, pixels, vae, mask_erosion) + positive, negative, latent = InpaintModelConditioning().encode(positive, negative, pixels, vae, mask) if additional == "Differential Diffusion": cls = ALL_NODE_CLASS_MAPPINGS['DifferentialDiffusion'] if cls is not None: