{"record":{"id":"8bbeb296c6a84757","repo":"Comfy-Org/ComfyUI","slug":"no-valid-images-found-in-input","errorCode":null,"errorMessage":"No valid images found in input","messagePattern":"No valid images found in input","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_dataset.py","lineNumber":28,"sourceCode":"\nimport folder_paths\nimport node_helpers\nfrom comfy_api.latest import ComfyExtension, io, Input, InputImpl, Types\n\n\ndef load_and_process_images(image_files, input_dir):\n    \"\"\"Utility function to load and process a list of images.\n\n    Args:\n        image_files: List of image filenames\n        input_dir: Base directory containing the images\n        resize_method: How to handle images of different sizes (\"None\", \"Stretch\", \"Crop\", \"Pad\")\n\n    Returns:\n        torch.Tensor: Batch of processed images\n    \"\"\"\n    if not image_files:\n        raise ValueError(\"No valid images found in input\")\n\n    output_images = []\n\n    for file in image_files:\n        image_path = os.path.join(input_dir, file)\n        img = node_helpers.pillow(Image.open, image_path)\n\n        if img.mode == \"I\":\n            img = img.point(lambda i: i * (1 / 255))\n        img = img.convert(\"RGB\")\n        img_array = np.array(img).astype(np.float32) / 255.0\n        img_tensor = torch.from_numpy(img_array)[None,]\n        output_images.append(img_tensor)\n\n    return output_images\n\n\ndef secure_subfolder_path(base_dir, folder_name):","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_dataset.py#L10-L46","documentation":"load_and_process_images is the shared loader for the dataset nodes; an empty (or None) image_files list raises immediately because there is nothing to stack into a batch tensor. The function has no silent-empty path by design — an empty dataset would produce a zero-length tensor that breaks downstream batching, so it fails fast with a clear message.","triggerScenarios":"Calling the loader with [] or None, which typically happens after a directory listing filter matched nothing — e.g. the folder exists but contains no image files, or every file was excluded by the extension filter.","commonSituations":"Pointing LoadDataSet nodes at an empty or misnamed folder; a filter glob that doesn't match (wrong extension case or the folder only has .txt caption files); a previous step moved/renamed the images.","solutions":["Verify the folder actually contains image files and that the extension filter matches them.","Fix the folder_name / path so it points at the dataset directory that holds the images.","If the empty case is legitimate in your workflow, check the file list before calling the node and skip with a message instead."],"exampleFix":"# before\nimage_files = [f for f in os.listdir(d) if f.endswith(\".png\")]  # folder has only .jpg\n# after\nimage_files = [f for f in os.listdir(d) if f.lower().endswith((\".png\", \".jpg\", \".jpeg\", \".webp\"))]","handlingStrategy":"validation","validationCode":"IMG_EXT = (\".png\", \".jpg\", \".jpeg\", \".webp\", \".bmp\")\ndef find_images(d):\n    files = [f for f in os.listdir(d) if f.lower().endswith(IMG_EXT)]\n    if not files:\n        raise FileNotFoundError(f\"no images in {d}\")\n    return files","typeGuard":"def has_images(files: list) -> bool:\n    return bool(files)","tryCatchPattern":null,"preventionTips":["Check the filtered file list is non-empty before calling the loader.","Use case-insensitive extension matching.","Verify the folder path points at the directory that holds the images."],"tags":["dataset","empty-input","comfyui"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}