mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-15 07:44:30 +08:00
Update nodes.py
This commit is contained in:
parent
aa54cbb6cf
commit
ccce5cc2b1
10
nodes.py
10
nodes.py
@ -510,15 +510,15 @@ class GetImagesFromBatchIndexed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def indexedimagesfrombatch(self, images, indexes):
|
def indexedimagesfrombatch(self, images, indexes):
|
||||||
|
|
||||||
# Parse the indexes string into a list of integers
|
# Parse the indexes string into a list of integers
|
||||||
index_list = [int(index.strip()) for index in indexes.split(',')]
|
index_list = [int(index.strip()) for index in indexes.split(',')]
|
||||||
|
|
||||||
# Fetch images based on parsed indexes
|
# Convert list of indices to a PyTorch tensor
|
||||||
chosen_images = [images[index] for index in index_list if 0 <= index < len(images)]
|
indices_tensor = torch.tensor(index_list, dtype=torch.long)
|
||||||
|
|
||||||
# Check if any index was out of range and raise an error if so
|
# Select the images at the specified indices
|
||||||
if len(chosen_images) != len(index_list):
|
chosen_images = images[indices_tensor]
|
||||||
raise ValueError("One or more indexes are out of range")
|
|
||||||
|
|
||||||
return (chosen_images,)
|
return (chosen_images,)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user