Fix ImageListSampler to correctly handle list input in ComfyUI

This commit is contained in:
Marco
2026-04-10 23:06:11 -03:00
parent 9b8c96724c
commit 9c7bdf8636
+11 -10
View File
@@ -10,23 +10,24 @@ class ImageListSampler:
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("sampled_images",)
INPUT_IS_LIST = True
OUTPUT_IS_LIST = (True,)
FUNCTION = "sample_images"
CATEGORY = "AnotherUtils/logic"
def sample_images(self, images, count):
if not isinstance(images, list):
# If it's a batch tensor [B, H, W, C], convert to list because logic expects list input
# However, if it's already a list of tokens, we just use it.
# In ComfyUI, if INPUT is simple "IMAGE", it might be a single tensor.
# But if we were called with a list, 'images' is a list.
pass
# When INPUT_IS_LIST is True, all inputs arrive as lists
# Unwrap parameters that should be single values
cnt = count[0] if isinstance(count, list) else count
if not images:
return ([],)
total = len(images)
if count <= 0:
if cnt <= 0:
return ([],)
if count >= total:
if cnt >= total:
return (images,)
# Calculate equally spaced indices
@@ -35,8 +36,8 @@ class ImageListSampler:
# i=0 -> 0
# i=1 -> 3
# i=2 -> 6
step = total / count
indices = [int(i * step) for i in range(count)]
step = total / cnt
indices = [int(i * step) for i in range(cnt)]
sampled = [images[i] for i in indices]