diff --git a/logic_management/image_list_sampler.py b/logic_management/image_list_sampler.py index c36712d..81c5ad4 100644 --- a/logic_management/image_list_sampler.py +++ b/logic_management/image_list_sampler.py @@ -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]