fix: Image grid bug fix (CORE-215)#14100
Conversation
📝 WalkthroughWalkthroughThis PR adds image input normalization to ImageProcessingNode. A new _ensure_image_list classmethod converts 4D tensors into a flat list of 3D image tensors, wraps 3D tensors as single entries, and flattens list/tuple inputs containing 4D tensors. ImageProcessingNode.execute now calls this helper when is_group is true before extracting parameters and calling _group_process. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_extras/nodes_dataset.py`:
- Line 463: The call to cls._ensure_image_list(images) forces images to a list
and breaks the single-image contract of _process; restore the original interface
by only normalizing to a list for batch processing or, if mode is
"individual"/single, pass a single image into _process (e.g., detect
original_is_list = isinstance(orig_images, list) or check the node's mode
variable, call cls._ensure_image_list only when batch, or if already converted
call _process(images[0]) and return a single result), and ensure _process,
_ensure_image_list and any dispatch logic around images preserve the original
input type/return semantics.
- Around line 409-415: The current flattening loop over images only unwraps one
level and lets nested lists/tuples through; update the function containing this
code to recursively traverse nested list/tuple items (detect collections via
isinstance(item, (list, tuple))) and flatten them fully: if an item is a
list/tuple, recurse into it; if it is a torch.Tensor and item.ndim == 4, extend
flat with each sample item[i]; otherwise append the tensor or scalar. Keep the
existing torch.Tensor and ndim==4 handling (the variables images, flat, and
item) but replace the non-recursive loop with a small recursive helper or
stack-based iteration to ensure no nested containers leak into the returned flat
list.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a0147ade-3201-422d-8ec6-47b677a4c349
📒 Files selected for processing (1)
comfy_extras/nodes_dataset.py
this contains handling for batched images for the image grid node


it unpacks batched images and batched images inside lists and tuples
before and after images are below