-
Notifications
You must be signed in to change notification settings - Fork 5
/
flux_controlnet_node.py
40 lines (34 loc) · 1.23 KB
/
flux_controlnet_node.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class FluxControlNetApply:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"conditioning": ("CONDITIONING", ),
"control_net": ("CONTROL_NET", ),
"image": ("IMAGE", ),
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01})
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "flux_controlnet"
CATEGORY = "ControlAltAI Nodes/Flux"
def flux_controlnet(self, conditioning, control_net, image, strength):
if strength == 0:
return (conditioning,)
c = []
control_hint = image.movedim(-1, 1)
for t in conditioning:
n = [t[0], t[1].copy()]
c_net = control_net.copy().set_cond_hint(control_hint, strength)
if 'control' in t[1]:
c_net.set_previous_controlnet(t[1]['control'])
n[1]['control'] = c_net
n[1]['control_apply_to_uncond'] = False # This ensures it's only applied to positive
c.append(n)
return (c,)
NODE_CLASS_MAPPINGS = {
"FluxControlNetApply": FluxControlNetApply,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"FluxControlNetApply": "Flux ControlNet",
}