mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 14:25:44 -03:00
0.34
This commit is contained in:
32
select_image_from_list.py
Normal file
32
select_image_from_list.py
Normal 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,)
|
||||
Reference in New Issue
Block a user