|
|
|
@ -602,9 +602,56 @@ class ControlNetApply:
|
|
|
|
|
if 'control' in t[1]: |
|
|
|
|
c_net.set_previous_controlnet(t[1]['control']) |
|
|
|
|
n[1]['control'] = c_net |
|
|
|
|
n[1]['control_apply_to_uncond'] = True |
|
|
|
|
c.append(n) |
|
|
|
|
return (c, ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ControlNetApplyAdvanced: |
|
|
|
|
@classmethod |
|
|
|
|
def INPUT_TYPES(s): |
|
|
|
|
return {"required": {"positive": ("CONDITIONING", ), |
|
|
|
|
"negative": ("CONDITIONING", ), |
|
|
|
|
"control_net": ("CONTROL_NET", ), |
|
|
|
|
"image": ("IMAGE", ), |
|
|
|
|
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), |
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
RETURN_TYPES = ("CONDITIONING","CONDITIONING") |
|
|
|
|
RETURN_NAMES = ("positive", "negative") |
|
|
|
|
FUNCTION = "apply_controlnet" |
|
|
|
|
|
|
|
|
|
CATEGORY = "conditioning" |
|
|
|
|
|
|
|
|
|
def apply_controlnet(self, positive, negative, control_net, image, strength): |
|
|
|
|
if strength == 0: |
|
|
|
|
return (positive, negative) |
|
|
|
|
|
|
|
|
|
control_hint = image.movedim(-1,1) |
|
|
|
|
cnets = {} |
|
|
|
|
|
|
|
|
|
out = [] |
|
|
|
|
for conditioning in [positive, negative]: |
|
|
|
|
c = [] |
|
|
|
|
for t in conditioning: |
|
|
|
|
d = t[1].copy() |
|
|
|
|
|
|
|
|
|
prev_cnet = d.get('control', None) |
|
|
|
|
if prev_cnet in cnets: |
|
|
|
|
c_net = cnets[prev_cnet] |
|
|
|
|
else: |
|
|
|
|
c_net = control_net.copy().set_cond_hint(control_hint, strength) |
|
|
|
|
c_net.set_previous_controlnet(prev_cnet) |
|
|
|
|
cnets[prev_cnet] = c_net |
|
|
|
|
|
|
|
|
|
d['control'] = c_net |
|
|
|
|
d['control_apply_to_uncond'] = False |
|
|
|
|
n = [t[0], d] |
|
|
|
|
c.append(n) |
|
|
|
|
out.append(c) |
|
|
|
|
return (out[0], out[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UNETLoader: |
|
|
|
|
@classmethod |
|
|
|
|
def INPUT_TYPES(s): |
|
|
|
@ -1449,6 +1496,7 @@ NODE_CLASS_MAPPINGS = {
|
|
|
|
|
"StyleModelApply": StyleModelApply, |
|
|
|
|
"unCLIPConditioning": unCLIPConditioning, |
|
|
|
|
"ControlNetApply": ControlNetApply, |
|
|
|
|
"ControlNetApplyAdvanced": ControlNetApplyAdvanced, |
|
|
|
|
"ControlNetLoader": ControlNetLoader, |
|
|
|
|
"DiffControlNetLoader": DiffControlNetLoader, |
|
|
|
|
"StyleModelLoader": StyleModelLoader, |
|
|
|
@ -1495,6 +1543,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|
|
|
|
"ConditioningSetArea": "Conditioning (Set Area)", |
|
|
|
|
"ConditioningSetMask": "Conditioning (Set Mask)", |
|
|
|
|
"ControlNetApply": "Apply ControlNet", |
|
|
|
|
"ControlNetApplyAdvanced": "Apply ControlNet (Advanced)", |
|
|
|
|
# Latent |
|
|
|
|
"VAEEncodeForInpaint": "VAE Encode (for Inpainting)", |
|
|
|
|
"SetLatentNoiseMask": "Set Latent Noise Mask", |
|
|
|
|