From 73bdfaf639b762d10f0c70d0f5682322cdd772f0 Mon Sep 17 00:00:00 2001 From: ozbayb <17261091+ozbayb@users.noreply.github.com> Date: Tue, 12 May 2026 16:48:06 -0600 Subject: [PATCH] Clamp out-of-range negative batch_index to start of batch --- comfy_extras/nodes_images.py | 2 +- nodes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy_extras/nodes_images.py b/comfy_extras/nodes_images.py index 8bcb84c1a..e48b2ea2d 100644 --- a/comfy_extras/nodes_images.py +++ b/comfy_extras/nodes_images.py @@ -147,7 +147,7 @@ class ImageFromBatch(IO.ComfyNode): s_in = image if batch_index < 0: batch_index += s_in.shape[0] - batch_index = min(s_in.shape[0] - 1, batch_index) + batch_index = max(0, min(s_in.shape[0] - 1, batch_index)) length = min(s_in.shape[0] - batch_index, length) s = s_in[batch_index:batch_index + length].clone() return IO.NodeOutput(s) diff --git a/nodes.py b/nodes.py index 510048d9c..84dff0841 100644 --- a/nodes.py +++ b/nodes.py @@ -1234,7 +1234,7 @@ class LatentFromBatch: s_in = samples["samples"] if batch_index < 0: batch_index += s_in.shape[0] - batch_index = min(s_in.shape[0] - 1, batch_index) + batch_index = max(0, min(s_in.shape[0] - 1, batch_index)) length = min(s_in.shape[0] - batch_index, length) s["samples"] = s_in[batch_index:batch_index + length].clone() if "noise_mask" in samples: