feat: wildcard refresh
refactor: move wildcard load function to wildcards.py https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/492
This commit is contained in:
+1
-17
@@ -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 = {
|
||||
|
||||
@@ -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');
|
||||
};
|
||||
@@ -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
|
||||
|
||||
@@ -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()}
|
||||
|
||||
@@ -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<quantifier>\d+)#__(?P<keyword>[\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.")
|
||||
|
||||
+1
-1
@@ -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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user