This commit is contained in:
Yousef R. Gamaleldin 2026-05-26 10:56:47 +09:30 committed by GitHub
commit e37c996bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -393,6 +393,27 @@ class ImageProcessingNode(io.ComfyNode):
return has_group return has_group
@classmethod
def _ensure_image_list(cls, images):
"""Normalize to a flat list of individual (H,W,C) tensors."""
# raw tensor
if isinstance(images, torch.Tensor):
if images.ndim == 4:
return [images[i] for i in range(images.shape[0])]
if images.ndim == 3:
return [images]
raise ValueError(f"Unexpected image tensor ndim: {images.ndim}, shape: {images.shape}")
# flatten batched images inside a list/tuple
flat = []
for item in images:
if isinstance(item, torch.Tensor) and item.ndim == 4:
flat.extend([item[i] for i in range(item.shape[0])])
else:
flat.append(item)
return flat
@classmethod @classmethod
def define_schema(cls): def define_schema(cls):
if cls.node_id is None: if cls.node_id is None:
@ -440,6 +461,9 @@ class ImageProcessingNode(io.ComfyNode):
"""Execute the node. Routes to _process or _group_process based on mode.""" """Execute the node. Routes to _process or _group_process based on mode."""
is_group = cls._detect_processing_mode() is_group = cls._detect_processing_mode()
if is_group:
images = cls._ensure_image_list(images)
# Extract scalar values from lists for parameters # Extract scalar values from lists for parameters
params = {} params = {}
for k, v in kwargs.items(): for k, v in kwargs.items():