Comfy-Org/ComfyUI · error · ValueError
No valid images found in input
Error message
No valid images found in input
What it means
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.
Source
Thrown at comfy_extras/nodes_dataset.py:28
import folder_paths
import node_helpers
from comfy_api.latest import ComfyExtension, io, Input, InputImpl, Types
def load_and_process_images(image_files, input_dir):
"""Utility function to load and process a list of images.
Args:
image_files: List of image filenames
input_dir: Base directory containing the images
resize_method: How to handle images of different sizes ("None", "Stretch", "Crop", "Pad")
Returns:
torch.Tensor: Batch of processed images
"""
if not image_files:
raise ValueError("No valid images found in input")
output_images = []
for file in image_files:
image_path = os.path.join(input_dir, file)
img = node_helpers.pillow(Image.open, image_path)
if img.mode == "I":
img = img.point(lambda i: i * (1 / 255))
img = img.convert("RGB")
img_array = np.array(img).astype(np.float32) / 255.0
img_tensor = torch.from_numpy(img_array)[None,]
output_images.append(img_tensor)
return output_images
def secure_subfolder_path(base_dir, folder_name):View on GitHub (pinned to 1c6d8d45b3)
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.
Example fix
# before
image_files = [f for f in os.listdir(d) if f.endswith(".png")] # folder has only .jpg
# after
image_files = [f for f in os.listdir(d) if f.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))] Defensive patterns
Strategy: validation
Validate before calling
IMG_EXT = (".png", ".jpg", ".jpeg", ".webp", ".bmp")
def find_images(d):
files = [f for f in os.listdir(d) if f.lower().endswith(IMG_EXT)]
if not files:
raise FileNotFoundError(f"no images in {d}")
return files Type guard
def has_images(files: list) -> bool:
return bool(files) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No images provided to create_image_parts; at least one image
- Invalid folder name {folder_name!r}: resolves outside of {ba
- folder_name must name a subfolder of the datasets directory,
- Dataset folder {folder_name!r} not found in: {', '.join(root
- No video files found in {sub_input_dir}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/8bbeb296c6a84757.
Report an issue: GitHub.