42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import torch
|
|
|
|
class BatchImages_Tiled:
|
|
@classmethod
|
|
def INPUT_TYPES(s):
|
|
return {
|
|
"required": {
|
|
"image1": ("IMAGE",),
|
|
},
|
|
"optional": {
|
|
"image2": ("IMAGE",),
|
|
"image3": ("IMAGE",),
|
|
"image4": ("IMAGE",),
|
|
"image5": ("IMAGE",),
|
|
"image6": ("IMAGE",),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("IMAGE",)
|
|
FUNCTION = "batch"
|
|
CATEGORY = "SplitImage"
|
|
|
|
def batch(self, image1, **kwargs):
|
|
images = [image1]
|
|
for i in range(2, 7):
|
|
img = kwargs.get(f"image{i}", None)
|
|
if img is not None:
|
|
images.append(img)
|
|
|
|
# Ensure all images have the same dimensions (W, H, C)
|
|
# We take the first image as reference
|
|
ref_h, ref_w, ref_c = image1.shape[1:]
|
|
|
|
valid_images = []
|
|
for i, img in enumerate(images):
|
|
if img.shape[1:] != (ref_h, ref_w, ref_c):
|
|
print(f"BatchImages_Tiled: Warning, image{i+1} has different dimensions {img.shape[1:]} than image1 {ref_h, ref_w, ref_c}. Skipping.")
|
|
continue
|
|
valid_images.append(img)
|
|
|
|
return (torch.cat(valid_images, dim=0),)
|