Skip to content

Commit

Permalink
Add boolean to InpaintModelConditioning to disable the noise mask.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Nov 19, 2024
1 parent f498d85 commit 156a287
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def INPUT_TYPES(s):
"vae": ("VAE", ),
"pixels": ("IMAGE", ),
"mask": ("MASK", ),
"add_noise_mask": ("BOOLEAN", {"default": True, "tooltip": "Add a noise mask to the latent so sampling will only happen within the mask. Might improve results or completely break things depending on the model."}),
}}

RETURN_TYPES = ("CONDITIONING","CONDITIONING","LATENT")
Expand All @@ -390,7 +391,7 @@ def INPUT_TYPES(s):

CATEGORY = "conditioning/inpaint"

def encode(self, positive, negative, pixels, vae, mask):
def encode(self, positive, negative, pixels, vae, mask, add_noise_mask):
x = (pixels.shape[1] // 8) * 8
y = (pixels.shape[2] // 8) * 8
mask = torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(pixels.shape[1], pixels.shape[2]), mode="bilinear")
Expand All @@ -414,7 +415,8 @@ def encode(self, positive, negative, pixels, vae, mask):
out_latent = {}

out_latent["samples"] = orig_latent
out_latent["noise_mask"] = mask
if add_noise_mask:
out_latent["noise_mask"] = mask

out = []
for conditioning in [positive, negative]:
Expand Down

0 comments on commit 156a287

Please sign in to comment.