Skip to content

Commit ca08597

Browse files
Make the inpaint controlnet node work with non inpaint ones.
1 parent f48e390 commit ca08597

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

comfy_extras/nodes_controlnet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ def INPUT_TYPES(s):
4343
CATEGORY = "conditioning/controlnet"
4444

4545
def apply_inpaint_controlnet(self, positive, negative, control_net, vae, image, mask, strength, start_percent, end_percent):
46-
mask = 1.0 - mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1]))
47-
mask_apply = comfy.utils.common_upscale(mask, image.shape[2], image.shape[1], "bilinear", "center").round()
48-
image = image * mask_apply.movedim(1, -1).repeat(1, 1, 1, image.shape[3])
49-
return self.apply_controlnet(positive, negative, control_net, image, strength, start_percent, end_percent, vae=vae, extra_concat=[mask])
46+
extra_concat = []
47+
if control_net.concat_mask:
48+
mask = 1.0 - mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1]))
49+
mask_apply = comfy.utils.common_upscale(mask, image.shape[2], image.shape[1], "bilinear", "center").round()
50+
image = image * mask_apply.movedim(1, -1).repeat(1, 1, 1, image.shape[3])
51+
extra_concat = [mask]
52+
53+
return self.apply_controlnet(positive, negative, control_net, image, strength, start_percent, end_percent, vae=vae, extra_concat=extra_concat)
5054

5155

5256

0 commit comments

Comments
 (0)