diff --git a/adv_control/control_sparsectrl.py b/adv_control/control_sparsectrl.py index 26c3956..9532d47 100644 --- a/adv_control/control_sparsectrl.py +++ b/adv_control/control_sparsectrl.py @@ -196,6 +196,11 @@ class SparseContextAware: class SparseSettings: def __init__(self, sparse_method: 'SparseMethod', use_motion: bool=True, motion_strength=1.0, motion_scale=1.0, merged=False, sparse_mask_mult=1.0, sparse_hint_mult=1.0, sparse_nonhint_mult=1.0, context_aware=SparseContextAware.NEAREST_HINT): + # account for Steerable-Motion workflow incompatibility; + # doing this to for my own peace of mind (not an issue with my code) + if type(sparse_method) == str: + 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.") + sparse_method = SparseIndexMethod(get_idx_list_from_str(sparse_method)) self.sparse_method = sparse_method self.use_motion = use_motion self.motion_strength = motion_strength @@ -356,6 +361,25 @@ def _get_indexes(self, hint_length: int, full_length: int) -> list[int]: return new_idxs +def get_idx_list_from_str(indexes: str) -> list[int]: + idxs = [] + unique_idxs = set() + # get indeces from string + str_idxs = [x.strip() for x in indexes.strip().split(",")] + for str_idx in str_idxs: + try: + idx = int(str_idx) + if idx in unique_idxs: + raise ValueError(f"'{idx}' is duplicated; indexes must be unique.") + idxs.append(idx) + unique_idxs.add(idx) + except ValueError: + raise ValueError(f"'{str_idx}' is not a valid integer index.") + if len(idxs) == 0: + raise ValueError(f"No indexes were listed in Sparse Index Method.") + return idxs + + ######################################### # motion-related portion of controlnet class BlockType: diff --git a/adv_control/nodes_sparsectrl.py b/adv_control/nodes_sparsectrl.py index 9fde905..8bae956 100644 --- a/adv_control/nodes_sparsectrl.py +++ b/adv_control/nodes_sparsectrl.py @@ -6,7 +6,7 @@ from comfy.sd import VAE from .utils import TimestepKeyframeGroup -from .control_sparsectrl import SparseMethod, SparseIndexMethod, SparseSettings, SparseSpreadMethod, PreprocSparseRGBWrapper, SparseConst, SparseContextAware +from .control_sparsectrl import SparseMethod, SparseIndexMethod, SparseSettings, SparseSpreadMethod, PreprocSparseRGBWrapper, SparseConst, SparseContextAware, get_idx_list_from_str from .control import load_sparsectrl, load_controlnet, ControlNetAdvanced, SparseCtrlAdvanced @@ -103,21 +103,7 @@ def INPUT_TYPES(s): CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝/SparseCtrl" def get_method(self, indexes: str): - idxs = [] - unique_idxs = set() - # get indeces from string - str_idxs = [x.strip() for x in indexes.strip().split(",")] - for str_idx in str_idxs: - try: - idx = int(str_idx) - if idx in unique_idxs: - raise ValueError(f"'{idx}' is duplicated; indexes must be unique.") - idxs.append(idx) - unique_idxs.add(idx) - except ValueError: - raise ValueError(f"'{str_idx}' is not a valid integer index.") - if len(idxs) == 0: - raise ValueError(f"No indexes were listed in Sparse Index Method.") + idxs = get_idx_list_from_str(indexes) return (SparseIndexMethod(idxs),) diff --git a/pyproject.toml b/pyproject.toml index 6b0be65..ec71e2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-advanced-controlnet" description = "Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks." -version = "1.0.4" +version = "1.0.5" license = "LICENSE" dependencies = []