Skip to content

Commit 7758b9b

Browse files
authored
fix: Image grid bug fix (CORE-215) (Comfy-Org#14100)
1 parent bb84c75 commit 7758b9b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

comfy_extras/nodes_dataset.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,21 @@ def _detect_processing_mode(cls):
411411

412412
return has_group
413413

414+
@classmethod
415+
def _ensure_image_list(cls, images):
416+
"""Normalize to a flat list of [1, H, W, C] tensors."""
417+
if isinstance(images, torch.Tensor):
418+
if images.ndim != 4:
419+
raise ValueError(f"Expected 4D image tensor, got shape {tuple(images.shape)}")
420+
return [images[i:i+1] for i in range(images.shape[0])]
421+
422+
flat = []
423+
for item in images:
424+
if not isinstance(item, torch.Tensor) or item.ndim != 4:
425+
raise ValueError(f"Expected 4D image tensor, got {type(item).__name__} shape {getattr(item, 'shape', None)}")
426+
flat.extend([item[i:i+1] for i in range(item.shape[0])])
427+
return flat
428+
414429
@classmethod
415430
def define_schema(cls):
416431
if cls.node_id is None:
@@ -458,6 +473,9 @@ def execute(cls, images, **kwargs):
458473
"""Execute the node. Routes to _process or _group_process based on mode."""
459474
is_group = cls._detect_processing_mode()
460475

476+
if is_group:
477+
images = cls._ensure_image_list(images)
478+
461479
# Extract scalar values from lists for parameters
462480
params = {}
463481
for k, v in kwargs.items():

0 commit comments

Comments
 (0)