From d25a42aad399caf84d30e67be0700048d4da2e43 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Wed, 8 Nov 2023 00:01:47 +0900 Subject: [PATCH] optimize: wildcard selector may slow down object_info transfer --- js/impact-pack.js | 23 ++++++++++++++++++----- modules/impact/config.py | 2 +- modules/impact/impact_pack.py | 4 ++-- modules/impact/impact_server.py | 6 ++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/js/impact-pack.js b/js/impact-pack.js index 305b2bb..fdb3334 100644 --- a/js/impact-pack.js +++ b/js/impact-pack.js @@ -2,6 +2,16 @@ import { ComfyApp, app } from "../../scripts/app.js"; import { ComfyDialog, $el } from "../../scripts/ui.js"; import { api } from "../../scripts/api.js"; +let wildcards_list = []; +async function load_wildcards() { + let res = await api.fetchApi('/impact/wildcards/list'); + let data = await res.json(); + wildcards_list = data.data; +} + +load_wildcards(); + + // temporary implementation (copying from https://github.com/pythongosssss/ComfyUI-WD14-Tagger) // I think this should be included into master!! class ImpactProgressBadge { @@ -531,12 +541,15 @@ app.registerExtension({ node.widgets[tbox_id].value += value; } } - - node._wvalue = value; }, - get: () => { - return node._wvalue; - } + get: () => { return "Select the Wildcard to add to the text"; } + }); + + Object.defineProperty(node.widgets[combo_id+1].options, "values", { + set: (x) => {}, + get: () => { + return wildcards_list; + } }); if(has_lora) { diff --git a/modules/impact/config.py b/modules/impact/config.py index a4babb8..5766d35 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version = "V4.30.1" +version = "V4.30.2" dependency_version = 17 diff --git a/modules/impact/impact_pack.py b/modules/impact/impact_pack.py index 249461e..245b9cb 100644 --- a/modules/impact/impact_pack.py +++ b/modules/impact/impact_pack.py @@ -2011,7 +2011,7 @@ class ImpactWildcardProcessor: "populated_text": ("STRING", {"multiline": True, "dynamicPrompts": False}), "mode": ("BOOLEAN", {"default": True, "label_on": "Populate", "label_off": "Fixed"}), "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}), - "Select to add Wildcard": (["Select the Wildcard to add to the text"] + impact.wildcards.get_wildcard_list(), ), + "Select to add Wildcard": (["Select the Wildcard to add to the text"],), }, } @@ -2035,7 +2035,7 @@ class ImpactWildcardEncode: "populated_text": ("STRING", {"multiline": True, "dynamicPrompts": False}), "mode": ("BOOLEAN", {"default": True, "label_on": "Populate", "label_off": "Fixed"}), "Select to add LoRA": (["Select the LoRA to add to the text"] + folder_paths.get_filename_list("loras"), ), - "Select to add Wildcard": (["Select the Wildcard to add to the text"] + impact.wildcards.get_wildcard_list(), ), + "Select to add Wildcard": (["Select the Wildcard to add to the text"], ), "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}), }, } diff --git a/modules/impact/impact_server.py b/modules/impact/impact_server.py index 136b9c2..8640ad0 100644 --- a/modules/impact/impact_server.py +++ b/modules/impact/impact_server.py @@ -189,6 +189,12 @@ async def sam_detect(request): return web.Response(status=400) +@server.PromptServer.instance.routes.get("/impact/wildcards/list") +async def wildcards_list(request): + data = {'data': impact.wildcards.get_wildcard_list()} + return web.json_response(data) + + @server.PromptServer.instance.routes.post("/impact/wildcards") async def populate_wildcards(request): data = await request.json()