Clamp out-of-range negative batch_index to start of batch

This commit is contained in:
ozbayb 2026-05-12 16:48:06 -06:00
parent a927795108
commit 73bdfaf639
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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: