-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathrandom_image.py
32 lines (25 loc) · 951 Bytes
/
random_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import random
class RandomImage:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"number_of_images": ("INT", {"default": 2, "min": 1, "max": 10, "step": 1}),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "random_image"
CATEGORY = "Bjornulf"
def random_image(self, number_of_images, **kwargs):
valid_images = []
for i in range(1, number_of_images + 1):
image_key = f"image_{i}"
if image_key in kwargs and kwargs[image_key] is not None:
valid_images.append(kwargs[image_key])
if not valid_images:
raise ValueError("No valid images provided")
random_image = random.choice(valid_images)
return (random_image,)
@classmethod
def IS_CHANGED(cls, number_of_images, ** kwargs):
return float("nan") # This will force the node to always update