From ccce5cc2b17d6b6954ea65272874db3f63b74db1 Mon Sep 17 00:00:00 2001 From: Kijai <40791699+kijai@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:08:06 +0200 Subject: [PATCH] Update nodes.py --- nodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nodes.py b/nodes.py index 16adc51..75deebe 100644 --- a/nodes.py +++ b/nodes.py @@ -510,15 +510,15 @@ class GetImagesFromBatchIndexed: } def indexedimagesfrombatch(self, images, indexes): + # Parse the indexes string into a list of integers index_list = [int(index.strip()) for index in indexes.split(',')] - # Fetch images based on parsed indexes - chosen_images = [images[index] for index in index_list if 0 <= index < len(images)] + # Convert list of indices to a PyTorch tensor + indices_tensor = torch.tensor(index_list, dtype=torch.long) - # Check if any index was out of range and raise an error if so - if len(chosen_images) != len(index_list): - raise ValueError("One or more indexes are out of range") + # Select the images at the specified indices + chosen_images = images[indices_tensor] return (chosen_images,)