diff --git a/__init__.py b/__init__.py index ffa022d..fb8f5ce 100644 --- a/__init__.py +++ b/__init__.py @@ -15,8 +15,6 @@ comfy_path = os.path.dirname(folder_paths.__file__) impact_path = os.path.join(os.path.dirname(__file__)) subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack") modules_path = os.path.join(os.path.dirname(__file__), "modules") -wildcards_path = os.path.join(os.path.dirname(__file__), "wildcards") -custom_wildcards_path = os.path.join(os.path.dirname(__file__), "custom_wildcards") sys.path.append(modules_path) @@ -88,22 +86,8 @@ from .modules.impact.segs_upscaler import * import threading -wildcard_path = impact.config.get_config()['custom_wildcards'] - -def wildcard_load(): - with wildcards.wildcard_lock: - impact.wildcards.read_wildcard_dict(wildcards_path) - - try: - impact.wildcards.read_wildcard_dict(impact.config.get_config()['custom_wildcards']) - except Exception as e: - print(f"[Impact Pack] Failed to load custom wildcards directory.") - - print(f"[Impact Pack] Wildcards loading done.") - - -threading.Thread(target=wildcard_load).start() +threading.Thread(target=impact.wildcards.wildcard_load).start() NODE_CLASS_MAPPINGS = { diff --git a/js/impact-wildcard.js b/js/impact-wildcard.js new file mode 100644 index 0000000..2cb635a --- /dev/null +++ b/js/impact-wildcard.js @@ -0,0 +1,11 @@ +import { ComfyApp, app } from "../../scripts/app.js"; +import { api } from "../../scripts/api.js"; + +let refresh_btn = document.getElementById('comfy-refresh-button'); + +let orig = refresh_btn.onclick; + +refresh_btn.onclick = function() { + orig(); + api.fetchApi('/impact/wildcards/refresh'); +}; diff --git a/modules/impact/config.py b/modules/impact/config.py index bb554d7..59ba6a7 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version_code = [5, 7] +version_code = [5, 8] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 20 diff --git a/modules/impact/impact_server.py b/modules/impact/impact_server.py index 993726d..823c075 100644 --- a/modules/impact/impact_server.py +++ b/modules/impact/impact_server.py @@ -194,6 +194,12 @@ async def sam_detect(request): return web.Response(status=400) +@PromptServer.instance.routes.get("/impact/wildcards/refresh") +async def wildcards_refresh(request): + impact.wildcards.wildcard_load() + return web.Response(status=200) + + @PromptServer.instance.routes.get("/impact/wildcards/list") async def wildcards_list(request): data = {'data': impact.wildcards.get_wildcard_list()} diff --git a/modules/impact/wildcards.py b/modules/impact/wildcards.py index 2a2b54f..9459c5d 100644 --- a/modules/impact/wildcards.py +++ b/modules/impact/wildcards.py @@ -7,6 +7,10 @@ import yaml import numpy as np import threading from impact import utils +from impact import config + + +wildcards_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "wildcards")) RE_WildCardQuantifier = re.compile(r"(?P\d+)#__(?P[\w.\-+/*\\]+)__", re.IGNORECASE) wildcard_lock = threading.Lock() @@ -499,3 +503,18 @@ def process_wildcard_for_segs(wildcard): else: return None, WildcardChooser([(None, wildcard)], False) + + +def wildcard_load(): + global wildcard_dict + wildcard_dict = {} + + with wildcard_lock: + read_wildcard_dict(wildcards_path) + + try: + read_wildcard_dict(config.get_config()['custom_wildcards']) + except Exception as e: + print(f"[Impact Pack] Failed to load custom wildcards directory.") + + print(f"[Impact Pack] Wildcards loading done.") diff --git a/pyproject.toml b/pyproject.toml index 17cbed6..8db27c7 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 = "5.7" +version = "5.8" license = "LICENSE" dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]