From 89a44028b50c12272a4990f8fa5b2a753f4ba7e2 Mon Sep 17 00:00:00 2001 From: InpaintRegionEditor Dev Date: Tue, 3 Mar 2026 18:59:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20VALIDATE=5FINPUTS?= =?UTF-8?q?=20=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 VALIDATE_INPUTS 方法使用文件存在性检查 - 支持 MaskEditor 保存后的 clipspace 子目录文件 - 递归获取 input 目录下所有文件(包括子目录) --- nodes.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/nodes.py b/nodes.py index ed6cf0c..3c12db9 100644 --- a/nodes.py +++ b/nodes.py @@ -25,16 +25,23 @@ class InpaintRegionEditor: @classmethod def INPUT_TYPES(s): - files = folder_paths.get_filename_list("input") + input_dir = folder_paths.get_input_directory() + files = [] + # 递归获取所有文件(包括子目录) + for root, dirs, filenames in os.walk(input_dir): + for f in filenames: + # 相对于 input 目录的路径(统一使用 / 分隔符) + rel_path = os.path.relpath(os.path.join(root, f), input_dir) + rel_path = rel_path.replace("\\", "/") # Windows 路径修复 + files.append(rel_path) + files = folder_paths.filter_files_content_types(files, ["image"]) return { "required": { "image": (sorted(files), {"image_upload": True}), "padding": ("INT", {"default": 64, "min": 0, "max": 512, "step": 32}), }, - "hidden": { - "region_coords": "STRING", - }, + "hidden": {"region_coords": "STRING"}, } RETURN_TYPES = ("IMAGE", "MASK", "INT", "INT", "INT", "INT") @@ -49,6 +56,14 @@ class InpaintRegionEditor: FUNCTION = "process" CATEGORY = "image/inpaint" + @classmethod + def VALIDATE_INPUTS(s, image, padding, region_coords=None): + # 使用文件存在性检查,而不是列表验证 + # 这样可以支持 MaskEditor 保存后的 clipspace 文件 + if not folder_paths.exists_annotated_filepath(image): + return "Invalid image file: {}".format(image) + return True + def process(self, image, padding, region_coords=None): image_path = folder_paths.get_annotated_filepath(image) img = Image.open(image_path)