mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-12 22:37:06 +08:00
add control_weight support for HunyuanDit Controlnet
This commit is contained in:
parent
bda7c82134
commit
e724bd542c
@ -240,6 +240,7 @@ class HunYuanControlNet(nn.Module):
|
|||||||
text_embedding_mask_t5=None,
|
text_embedding_mask_t5=None,
|
||||||
image_meta_size=None,
|
image_meta_size=None,
|
||||||
style=None,
|
style=None,
|
||||||
|
control_weight=1.0,
|
||||||
transformer_options=None,
|
transformer_options=None,
|
||||||
**kwarg,
|
**kwarg,
|
||||||
):
|
):
|
||||||
@ -336,4 +337,6 @@ class HunYuanControlNet(nn.Module):
|
|||||||
x = block(x, c, text_states, freqs_cis_img)
|
x = block(x, c, text_states, freqs_cis_img)
|
||||||
controls.append(self.after_proj_list[layer](x)) # zero linear for output
|
controls.append(self.after_proj_list[layer](x)) # zero linear for output
|
||||||
|
|
||||||
|
controls = [control * control_weight for control in controls]
|
||||||
|
|
||||||
return {"output": controls}
|
return {"output": controls}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ class ControlNetApplyAdvancedHunYuan:
|
|||||||
"image": ("IMAGE", ),
|
"image": ("IMAGE", ),
|
||||||
"vae": ("VAE", ),
|
"vae": ("VAE", ),
|
||||||
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||||
|
"control_weight": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.001}),
|
||||||
"start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
|
"start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
|
||||||
"end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001})
|
"end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001})
|
||||||
}}
|
}}
|
||||||
@ -39,7 +40,7 @@ class ControlNetApplyAdvancedHunYuan:
|
|||||||
|
|
||||||
CATEGORY = "conditioning/controlnet"
|
CATEGORY = "conditioning/controlnet"
|
||||||
|
|
||||||
def apply_controlnet(self, positive, negative, control_net, image, strength, start_percent, end_percent, vae=None):
|
def apply_controlnet(self, positive, negative, control_net, image, strength, control_weight, start_percent, end_percent, vae=None):
|
||||||
if strength == 0:
|
if strength == 0:
|
||||||
return (positive, negative)
|
return (positive, negative)
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ class ControlNetApplyAdvancedHunYuan:
|
|||||||
c_net = cnets[prev_cnet]
|
c_net = cnets[prev_cnet]
|
||||||
else:
|
else:
|
||||||
c_net = control_net.copy().set_cond_hint(control_hint, strength, (start_percent, end_percent), vae)
|
c_net = control_net.copy().set_cond_hint(control_hint, strength, (start_percent, end_percent), vae)
|
||||||
|
c_net.set_extra_arg('control_weight', control_weight)
|
||||||
|
|
||||||
c_net.set_previous_controlnet(prev_cnet)
|
c_net.set_previous_controlnet(prev_cnet)
|
||||||
cnets[prev_cnet] = c_net
|
cnets[prev_cnet] = c_net
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user