Skip to content

Commit 95d00fc

Browse files
authored
Merge PR #131 from Kosinkadink/develop - node autosize + maintenance
Node Autosize + Maintenance
2 parents 56000f3 + 10ad2e6 commit 95d00fc

8 files changed

+70
-10
lines changed

__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .adv_control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
22

3-
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
3+
WEB_DIRECTORY = "./web"
4+
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"]

adv_control/nodes.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def INPUT_TYPES(s):
2626
"control_net_name": (folder_paths.get_filename_list("controlnet"), ),
2727
},
2828
"optional": {
29-
"timestep_keyframe": ("TIMESTEP_KEYFRAME", ),
29+
"tk_optional": ("TIMESTEP_KEYFRAME", ),
3030
}
3131
}
3232

@@ -36,10 +36,13 @@ def INPUT_TYPES(s):
3636
CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝"
3737

3838
def load_controlnet(self, control_net_name,
39-
timestep_keyframe: TimestepKeyframeGroup=None
39+
tk_optional: TimestepKeyframeGroup=None,
40+
timestep_keyframe: TimestepKeyframeGroup=None,
4041
):
42+
if timestep_keyframe is not None: # backwards compatibility
43+
tk_optional = timestep_keyframe
4144
controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
42-
controlnet = load_controlnet(controlnet_path, timestep_keyframe)
45+
controlnet = load_controlnet(controlnet_path, tk_optional)
4346
return (controlnet,)
4447

4548

@@ -52,7 +55,8 @@ def INPUT_TYPES(s):
5255
"control_net_name": (folder_paths.get_filename_list("controlnet"), )
5356
},
5457
"optional": {
55-
"timestep_keyframe": ("TIMESTEP_KEYFRAME", ),
58+
"tk_optional": ("TIMESTEP_KEYFRAME", ),
59+
"autosize": ("ACNAUTOSIZE", {"padding": 160}),
5660
}
5761
}
5862

@@ -62,10 +66,13 @@ def INPUT_TYPES(s):
6266
CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝"
6367

6468
def load_controlnet(self, control_net_name, model,
69+
tk_optional: TimestepKeyframeGroup=None,
6570
timestep_keyframe: TimestepKeyframeGroup=None
6671
):
72+
if timestep_keyframe is not None: # backwards compatibility
73+
tk_optional = timestep_keyframe
6774
controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
68-
controlnet = load_controlnet(controlnet_path, timestep_keyframe, model)
75+
controlnet = load_controlnet(controlnet_path, tk_optional, model)
6976
if is_advanced_controlnet(controlnet):
7077
controlnet.verify_all_weights()
7178
return (controlnet,)
@@ -91,6 +98,7 @@ def INPUT_TYPES(s):
9198
"weights_override": ("CONTROL_NET_WEIGHTS", ),
9299
"model_optional": ("MODEL",),
93100
"vae_optional": ("VAE",),
101+
"autosize": ("ACNAUTOSIZE", {"padding": 40}),
94102
}
95103
}
96104

adv_control/nodes_keyframes.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def INPUT_TYPES(s):
2525
"inherit_missing": ("BOOLEAN", {"default": True}, ),
2626
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
2727
"mask_optional": ("MASK", ),
28+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
2829
}
2930
}
3031

@@ -81,6 +82,7 @@ def INPUT_TYPES(s):
8182
"inherit_missing": ("BOOLEAN", {"default": True},),
8283
"mask_optional": ("MASK", ),
8384
"print_keyframes": ("BOOLEAN", {"default": False}),
85+
"autosize": ("ACNAUTOSIZE", {"padding": 70}),
8486
}
8587
}
8688

@@ -139,6 +141,7 @@ def INPUT_TYPES(s):
139141
"inherit_missing": ("BOOLEAN", {"default": True},),
140142
"mask_optional": ("MASK", ),
141143
"print_keyframes": ("BOOLEAN", {"default": False}),
144+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
142145
}
143146
}
144147

@@ -195,6 +198,7 @@ def INPUT_TYPES(s):
195198
},
196199
"optional": {
197200
"prev_latent_kf": ("LATENT_KEYFRAME", ),
201+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
198202
}
199203
}
200204

@@ -230,7 +234,8 @@ def INPUT_TYPES(s):
230234
"optional": {
231235
"prev_latent_kf": ("LATENT_KEYFRAME", ),
232236
"latent_optional": ("LATENT", ),
233-
"print_keyframes": ("BOOLEAN", {"default": False})
237+
"print_keyframes": ("BOOLEAN", {"default": False}),
238+
"autosize": ("ACNAUTOSIZE", {"padding": 35}),
234239
}
235240
}
236241

@@ -349,7 +354,8 @@ def INPUT_TYPES(s):
349354
},
350355
"optional": {
351356
"prev_latent_kf": ("LATENT_KEYFRAME", ),
352-
"print_keyframes": ("BOOLEAN", {"default": False})
357+
"print_keyframes": ("BOOLEAN", {"default": False}),
358+
"autosize": ("ACNAUTOSIZE", {"padding": 90}),
353359
}
354360
}
355361

@@ -419,7 +425,8 @@ def INPUT_TYPES(s):
419425
},
420426
"optional": {
421427
"prev_latent_kf": ("LATENT_KEYFRAME", ),
422-
"print_keyframes": ("BOOLEAN", {"default": False})
428+
"print_keyframes": ("BOOLEAN", {"default": False}),
429+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
423430
}
424431
}
425432

adv_control/nodes_plusplus.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def INPUT_TYPES(s):
6262
},
6363
"optional": {
6464
"prev_plus_input": ("PLUS_INPUT",),
65+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
6566
#"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": BIGMAX, "step": 0.01}),
6667
}
6768
}

adv_control/nodes_sparsectrl.py

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def INPUT_TYPES(s):
133133
"image": ("IMAGE", ),
134134
"vae": ("VAE", ),
135135
"latent_size": ("LATENT", ),
136+
},
137+
"optional": {
138+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
136139
}
137140
}
138141

@@ -165,6 +168,7 @@ def INPUT_TYPES(s):
165168
"sparse_hint_mult": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
166169
"sparse_nonhint_mult": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
167170
"sparse_mask_mult": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
171+
"autosize": ("ACNAUTOSIZE", {"padding": 50}),
168172
}
169173
}
170174

adv_control/nodes_weight.py

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def INPUT_TYPES(s):
1313
return {
1414
"optional": {
1515
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
16+
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
1617
}
1718
}
1819

@@ -41,6 +42,7 @@ def INPUT_TYPES(s):
4142
"optional": {
4243
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
4344
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
45+
"autosize": ("ACNAUTOSIZE", {"padding": 75}),
4446
}
4547
}
4648

@@ -75,6 +77,7 @@ def INPUT_TYPES(s):
7577
"optional": {
7678
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
7779
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
80+
"autosize": ("ACNAUTOSIZE", {"padding": 20}),
7881
}
7982
}
8083

@@ -112,6 +115,7 @@ def INPUT_TYPES(s):
112115
"optional": {
113116
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
114117
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
118+
"autosize": ("ACNAUTOSIZE", {"padding": 50}),
115119
}
116120
}
117121

@@ -153,6 +157,7 @@ def INPUT_TYPES(s):
153157
"optional": {
154158
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
155159
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
160+
"autosize": ("ACNAUTOSIZE", {"padding": 65}),
156161
}
157162
}
158163

@@ -185,6 +190,7 @@ def INPUT_TYPES(s):
185190
"optional": {
186191
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
187192
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
193+
"autosize": ("ACNAUTOSIZE", {"padding": 55}),
188194
}
189195
}
190196

@@ -217,6 +223,7 @@ def INPUT_TYPES(s):
217223
"optional": {
218224
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
219225
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
226+
"autosize": ("ACNAUTOSIZE", {"padding": 65}),
220227
}
221228
}
222229

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-advanced-controlnet"
33
description = "Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks."
4-
version = "1.1.1"
4+
version = "1.1.2"
55
license = "LICENSE"
66
dependencies = []
77

web/js/autosize.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { app } from '../../../scripts/app.js'
2+
app.registerExtension({
3+
name: "AdvancedControlNet.autosize",
4+
async nodeCreated(node) {
5+
if(node.acnAutosize) {
6+
let size = node.computeSize(0);
7+
size[0] += node.acnAutosize?.padding || 0;
8+
node.setSize(size);
9+
}
10+
},
11+
async getCustomWidgets() {
12+
return {
13+
ACNAUTOSIZE(node, inputName, inputData) {
14+
let w = {
15+
name : inputName,
16+
type : "ACN.AUTOSIZE",
17+
value : "",
18+
options : {"serialize": false},
19+
computeSize : function(width) {
20+
return [0, -4];
21+
}
22+
}
23+
node.acnAutosize = inputData[1];
24+
if (!node.widgets) {
25+
node.widgets = []
26+
}
27+
node.widgets.push(w)
28+
return w;
29+
}
30+
}
31+
}
32+
});

0 commit comments

Comments
 (0)