From 57bb55baca658b7956c598480b807ab1a93a7702 Mon Sep 17 00:00:00 2001 From: Symbiomatrix Date: Fri, 11 Apr 2025 16:19:23 +0300 Subject: [PATCH 1/2] Add input storage. --- folder_paths.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/folder_paths.py b/folder_paths.py index 72c70f59..bf931dd0 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -10,6 +10,7 @@ from collections.abc import Collection from comfy.cli_args import args supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'} +supported_input_extensions: set[str] = {""} # {".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".webp", ".webm", ".mp4", ".mkv"} folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {} @@ -51,6 +52,9 @@ temp_directory = os.path.join(base_path, "temp") input_directory = os.path.join(base_path, "input") user_directory = os.path.join(base_path, "user") +folder_names_and_paths["input"] = ([input_directory], supported_input_extensions) +folder_names_and_paths["latent"] = ([input_directory], {".latent"}) + filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {} class CacheHelper: From f52e089d863b9146dae662c0401ebffbba1c6e2a Mon Sep 17 00:00:00 2001 From: Symbiomatrix Date: Fri, 11 Apr 2025 16:24:08 +0300 Subject: [PATCH 2/2] Read input from storage. --- nodes.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/nodes.py b/nodes.py index 8c1720c1..14aee594 100644 --- a/nodes.py +++ b/nodes.py @@ -499,9 +499,10 @@ class SaveLatent: class LoadLatent: @classmethod def INPUT_TYPES(s): - input_dir = folder_paths.get_input_directory() - files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f)) and f.endswith(".latent")] - return {"required": {"latent": [sorted(files), ]}, } + return {"required": + {"latent": (folder_paths.get_filename_list("latent"), ) + }, + } CATEGORY = "_for_testing" @@ -1652,10 +1653,9 @@ class PreviewImage(SaveImage): class LoadImage: @classmethod def INPUT_TYPES(s): - input_dir = folder_paths.get_input_directory() - files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))] - return {"required": - {"image": (sorted(files), {"image_upload": True})}, + return {"required": + {"image": (folder_paths.get_filename_list("input"), {"image_upload": True}) + }, } CATEGORY = "image" @@ -1728,11 +1728,10 @@ class LoadImageMask: _color_channels = ["alpha", "red", "green", "blue"] @classmethod def INPUT_TYPES(s): - input_dir = folder_paths.get_input_directory() - files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))] - return {"required": - {"image": (sorted(files), {"image_upload": True}), - "channel": (s._color_channels, ), } + return {"required": + {"image": (folder_paths.get_filename_list("input"), {"image_upload": True}), + "channel": (s._color_channels, ), + }, } CATEGORY = "mask"