diff --git a/comfy_extras/nodes_upscale_model.py b/comfy_extras/nodes_upscale_model.py index 0f0f933a5..b79b78511 100644 --- a/comfy_extras/nodes_upscale_model.py +++ b/comfy_extras/nodes_upscale_model.py @@ -16,8 +16,6 @@ class UpscaleModelLoader: CATEGORY = "loaders" - REFRESH_LIST = ["model_name"] - def load_model(self, model_name): model_path = folder_paths.get_full_path("upscale_models", model_name) sd = load_torch_file(model_path) diff --git a/nodes.py b/nodes.py index 56ec92a56..6fb7f0175 100644 --- a/nodes.py +++ b/nodes.py @@ -199,8 +199,6 @@ class CheckpointLoader: CATEGORY = "loaders" - REFRESH_LIST = ["config_name", "ckpt_name"] - def load_checkpoint(self, config_name, ckpt_name, output_vae=True, output_clip=True): config_path = folder_paths.get_full_path("configs", config_name) ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name) @@ -216,8 +214,6 @@ class CheckpointLoaderSimple: CATEGORY = "loaders" - REFRESH_LIST = ["ckpt_name"] - def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True): ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name) out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings")) @@ -253,8 +249,6 @@ class LoraLoader: CATEGORY = "loaders" - REFRESH_LIST = ["lora_name"] - def load_lora(self, model, clip, lora_name, strength_model, strength_clip): lora_path = folder_paths.get_full_path("loras", lora_name) model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora_path, strength_model, strength_clip) @@ -269,8 +263,6 @@ class VAELoader: CATEGORY = "loaders" - REFRESH_LIST = ["vae_name"] - #TODO: scale factor? def load_vae(self, vae_name): vae_path = folder_paths.get_full_path("vae", vae_name) @@ -287,8 +279,6 @@ class ControlNetLoader: CATEGORY = "loaders" - REFRESH_LIST = ["control_net_name"] - def load_controlnet(self, control_net_name): controlnet_path = folder_paths.get_full_path("controlnet", control_net_name) controlnet = comfy.sd.load_controlnet(controlnet_path) @@ -305,8 +295,6 @@ class DiffControlNetLoader: CATEGORY = "loaders" - REFRESH_LIST = ["control_net_name"] - def load_controlnet(self, model, control_net_name): controlnet_path = folder_paths.get_full_path("controlnet", control_net_name) controlnet = comfy.sd.load_controlnet(controlnet_path, model) @@ -349,8 +337,6 @@ class CLIPLoader: CATEGORY = "loaders" - REFRESH_LIST = ["clip_name"] - def load_clip(self, clip_name): clip_path = folder_paths.get_full_path("clip", clip_name) clip = comfy.sd.load_clip(ckpt_path=clip_path, embedding_directory=folder_paths.get_folder_paths("embeddings")) @@ -366,8 +352,6 @@ class CLIPVisionLoader: CATEGORY = "loaders" - REFRESH_LIST = ["clip_name"] - def load_clip(self, clip_name): clip_path = folder_paths.get_full_path("clip_vision", clip_name) clip_vision = comfy_extras.clip_vision.load(clip_path) @@ -398,8 +382,6 @@ class StyleModelLoader: CATEGORY = "loaders" - REFRESH_LIST = ["style_model_name"] - def load_style_model(self, style_model_name): style_model_path = folder_paths.get_full_path("style_models", style_model_name) style_model = comfy.sd.load_style_model(style_model_path) @@ -840,9 +822,6 @@ class LoadImage: RETURN_TYPES = ("IMAGE", "MASK") FUNCTION = "load_image" - - REFRESH_LIST = ["image"] - def load_image(self, image): image_path = os.path.join(self.input_dir, image) i = Image.open(image_path) diff --git a/server.py b/server.py index 09f707850..80fb2dc72 100644 --- a/server.py +++ b/server.py @@ -158,8 +158,6 @@ class PromptServer(): info['category'] = 'sd' if hasattr(obj_class, 'CATEGORY'): info['category'] = obj_class.CATEGORY - if hasattr(obj_class, 'REFRESH_LIST'): - info['refresh_list'] = obj_class.REFRESH_LIST out[x] = info return web.json_response(out) diff --git a/web/scripts/app.js b/web/scripts/app.js index 602c3b21f..43d7f7b59 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -903,9 +903,9 @@ class ComfyApp { } /** - * Refresh file list on whole nodes + * Refresh combo list on whole nodes */ - async refreshNodes() { + async refreshComboInNodes() { const defs = await api.getNodeDefs(); for(let nodeNum in this.graph._nodes) { @@ -913,16 +913,16 @@ class ComfyApp { const def = defs[node.type]; - if(def.refresh_list == undefined) { - continue; - } + for(const widgetNum in node.widgets) { + const widget = node.widgets[widgetNum] - for(const i in def.refresh_list) { - const item = def.refresh_list[i]; - const filelist = def.input["required"][item]; - const w = node.widgets.find((w) => w.name === item); - w.options.values = filelist[0]; - w.value = w.options.values[0]; + if(widget.type == "combo" && def["input"]["required"][widget.name] !== undefined) { + widget.options.values = def["input"]["required"][widget.name][0]; + + if(!widget.options.values.includes(widget.value)) { + widget.value = widget.options.values[0]; + } + } } } } diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 836ae9311..2c3bf87c7 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -376,7 +376,7 @@ export class ComfyUI { }, }), $el("button", { textContent: "Load", onclick: () => fileInput.click() }), - $el("button", { textContent: "Refresh", onclick: () => app.refreshNodes() }), + $el("button", { textContent: "Refresh", onclick: () => app.refreshComboInNodes() }), $el("button", { textContent: "Clear", onclick: () => app.graph.clear() }), $el("button", { textContent: "Load Default", onclick: () => app.loadGraphData() }), ]);