This commit is contained in:
justumen
2024-09-16 10:36:11 +02:00
parent a3f930d8c6
commit 5f47d20f75
12 changed files with 176 additions and 9 deletions

32
select_image_from_list.py Normal file
View File

@@ -0,0 +1,32 @@
import torch
class Everything(str):
def __ne__(self, __value: object) -> bool:
return False
class SelectImageFromList:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"all_images": ("IMAGE", {}),
"selection": ("INT", {"default": 1, "min": 1, "max": 999, "step": 1}),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("selected_image",)
FUNCTION = "select_an_image"
CATEGORY = "Bjornulf"
def select_an_image(self, all_images, selection):
# Ensure the selection is within bounds
selection = max(1, min(selection, all_images.shape[0]))
# Adjust selection to 0-based index
index = selection - 1
# Select the image at the specified index
selected_image = all_images[index].unsqueeze(0)
return (selected_image,)