diff --git a/folder_paths.py b/folder_paths.py index 9c96540e3..1ef72d28b 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] = {""} folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {} @@ -57,6 +58,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: diff --git a/nodes.py b/nodes.py index 356aa63df..ef1bbfa7c 100644 --- a/nodes.py +++ b/nodes.py @@ -510,9 +510,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" @@ -1643,11 +1644,10 @@ 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))] + files = folder_paths.get_filename_list("input") files = folder_paths.filter_files_content_types(files, ["image"]) return {"required": - {"image": (sorted(files), {"image_upload": True})}, + {"image": (files, {"image_upload": True})}, } CATEGORY = "image" @@ -1720,11 +1720,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"