Skip to content

Commit

Permalink
Make the inpaint controlnet node work with non inpaint ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 14, 2024
1 parent f48e390 commit ca08597
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions comfy_extras/nodes_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ def INPUT_TYPES(s):
CATEGORY = "conditioning/controlnet"

def apply_inpaint_controlnet(self, positive, negative, control_net, vae, image, mask, strength, start_percent, end_percent):
mask = 1.0 - mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1]))
mask_apply = comfy.utils.common_upscale(mask, image.shape[2], image.shape[1], "bilinear", "center").round()
image = image * mask_apply.movedim(1, -1).repeat(1, 1, 1, image.shape[3])
return self.apply_controlnet(positive, negative, control_net, image, strength, start_percent, end_percent, vae=vae, extra_concat=[mask])
extra_concat = []
if control_net.concat_mask:
mask = 1.0 - mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1]))
mask_apply = comfy.utils.common_upscale(mask, image.shape[2], image.shape[1], "bilinear", "center").round()
image = image * mask_apply.movedim(1, -1).repeat(1, 1, 1, image.shape[3])
extra_concat = [mask]

return self.apply_controlnet(positive, negative, control_net, image, strength, start_percent, end_percent, vae=vae, extra_concat=extra_concat)



Expand Down

0 comments on commit ca08597

Please sign in to comment.