Skip to content

Commit bf16347

Browse files
authored
Merge pull request #122 from Kosinkadink/develop
Add automatic workaround for outdated Steerable-Motion workflow issue
2 parents f6adc32 + fa870f6 commit bf16347

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

adv_control/control_sparsectrl.py

+24
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ class SparseContextAware:
196196
class SparseSettings:
197197
def __init__(self, sparse_method: 'SparseMethod', use_motion: bool=True, motion_strength=1.0, motion_scale=1.0, merged=False,
198198
sparse_mask_mult=1.0, sparse_hint_mult=1.0, sparse_nonhint_mult=1.0, context_aware=SparseContextAware.NEAREST_HINT):
199+
# account for Steerable-Motion workflow incompatibility;
200+
# doing this to for my own peace of mind (not an issue with my code)
201+
if type(sparse_method) == str:
202+
logger.warn("Outdated Steerable-Motion workflow detected; attempting to auto-convert indexes input. If you experience an error here, consult Steerable-Motion github, NOT Advanced-ControlNet.")
203+
sparse_method = SparseIndexMethod(get_idx_list_from_str(sparse_method))
199204
self.sparse_method = sparse_method
200205
self.use_motion = use_motion
201206
self.motion_strength = motion_strength
@@ -356,6 +361,25 @@ def _get_indexes(self, hint_length: int, full_length: int) -> list[int]:
356361
return new_idxs
357362

358363

364+
def get_idx_list_from_str(indexes: str) -> list[int]:
365+
idxs = []
366+
unique_idxs = set()
367+
# get indeces from string
368+
str_idxs = [x.strip() for x in indexes.strip().split(",")]
369+
for str_idx in str_idxs:
370+
try:
371+
idx = int(str_idx)
372+
if idx in unique_idxs:
373+
raise ValueError(f"'{idx}' is duplicated; indexes must be unique.")
374+
idxs.append(idx)
375+
unique_idxs.add(idx)
376+
except ValueError:
377+
raise ValueError(f"'{str_idx}' is not a valid integer index.")
378+
if len(idxs) == 0:
379+
raise ValueError(f"No indexes were listed in Sparse Index Method.")
380+
return idxs
381+
382+
359383
#########################################
360384
# motion-related portion of controlnet
361385
class BlockType:

adv_control/nodes_sparsectrl.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from comfy.sd import VAE
77

88
from .utils import TimestepKeyframeGroup
9-
from .control_sparsectrl import SparseMethod, SparseIndexMethod, SparseSettings, SparseSpreadMethod, PreprocSparseRGBWrapper, SparseConst, SparseContextAware
9+
from .control_sparsectrl import SparseMethod, SparseIndexMethod, SparseSettings, SparseSpreadMethod, PreprocSparseRGBWrapper, SparseConst, SparseContextAware, get_idx_list_from_str
1010
from .control import load_sparsectrl, load_controlnet, ControlNetAdvanced, SparseCtrlAdvanced
1111

1212

@@ -103,21 +103,7 @@ def INPUT_TYPES(s):
103103
CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝/SparseCtrl"
104104

105105
def get_method(self, indexes: str):
106-
idxs = []
107-
unique_idxs = set()
108-
# get indeces from string
109-
str_idxs = [x.strip() for x in indexes.strip().split(",")]
110-
for str_idx in str_idxs:
111-
try:
112-
idx = int(str_idx)
113-
if idx in unique_idxs:
114-
raise ValueError(f"'{idx}' is duplicated; indexes must be unique.")
115-
idxs.append(idx)
116-
unique_idxs.add(idx)
117-
except ValueError:
118-
raise ValueError(f"'{str_idx}' is not a valid integer index.")
119-
if len(idxs) == 0:
120-
raise ValueError(f"No indexes were listed in Sparse Index Method.")
106+
idxs = get_idx_list_from_str(indexes)
121107
return (SparseIndexMethod(idxs),)
122108

123109

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.0.4"
4+
version = "1.0.5"
55
license = "LICENSE"
66
dependencies = []
77

0 commit comments

Comments
 (0)