From e325d1b208fec4ef97238a066786f598139c471c Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 24 Aug 2024 12:05:40 +0900 Subject: [PATCH] improve: InversedSwitch - now use ExecutionBlocker for unselected output --- modules/impact/config.py | 2 +- modules/impact/util_nodes.py | 20 ++++++++++++++++++-- pyproject.toml | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/impact/config.py b/modules/impact/config.py index 9fc0d2c..3f45d3c 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -1,7 +1,7 @@ import configparser import os -version_code = [7, 1, 1] +version_code = [7, 2] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 22 diff --git a/modules/impact/util_nodes.py b/modules/impact/util_nodes.py index 925514f..7eaed35 100644 --- a/modules/impact/util_nodes.py +++ b/modules/impact/util_nodes.py @@ -1,5 +1,6 @@ from impact.utils import any_typ, ByPassTypeTuple, make_3d_mask import comfy_extras.nodes_mask +from comfy_execution.graph import ExecutionBlocker from nodes import MAX_RESOLUTION import torch import comfy @@ -145,10 +146,12 @@ class GeneralInversedSwitch: return {"required": { "select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1}), "input": (any_typ,), + }, "optional": { "sel_mode": ("BOOLEAN", {"default": False, "label_on": "select_on_prompt", "label_off": "select_on_execution", "forceInput": False}), }, + "hidden": {"prompt": "PROMPT", "unique_id": "UNIQUE_ID"}, } RETURN_TYPES = ByPassTypeTuple((any_typ, )) @@ -156,12 +159,25 @@ class GeneralInversedSwitch: CATEGORY = "ImpactPack/Util" - def doit(self, select, input, **kwargs): + def doit(self, select, prompt, unique_id, input, **kwargs): + if core.is_execution_model_version_supported: + from comfy_execution.graph import ExecutionBlocker + res = [] - for i in range(0, select): + # search max output count in prompt + cnt = 0 + for x in prompt.values(): + for y in x.get('inputs', {}).values(): + if isinstance(y, list) and len(y) == 2: + if y[0] == unique_id: + cnt = max(cnt, y[1]) + + for i in range(0, cnt + 1): if select == i+1: res.append(input) + elif core.is_execution_model_version_supported: + res.append(ExecutionBlocker(None)) else: res.append(None) diff --git a/pyproject.toml b/pyproject.toml index ec045ee..5706e75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-impact-pack" description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." -version = "7.1.1" +version = "7.2" license = { file = "LICENSE.txt" } dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]