From f3e100b9b45e47bd58babcf6651eb0aa71a136a7 Mon Sep 17 00:00:00 2001 From: Moser9815 Date: Thu, 12 Mar 2026 17:07:01 -0400 Subject: [PATCH] Add RM Make Image Batch node Combines up to 5 images into a single batch, auto-resizing mismatched dimensions to match the first image. Co-Authored-By: Claude Opus 4.6 --- __init__.py | 4 +++ nodes/make_image_batch.py | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 nodes/make_image_batch.py diff --git a/__init__.py b/__init__.py index ae7c552..78c5b74 100644 --- a/__init__.py +++ b/__init__.py @@ -29,6 +29,8 @@ from .nodes.multi_detect_crop import NODE_CLASS_MAPPINGS as MULTI_DETECT_MAPPING from .nodes.multi_detect_crop import NODE_DISPLAY_NAME_MAPPINGS as MULTI_DETECT_DISPLAY from .nodes.math_expression import NODE_CLASS_MAPPINGS as MATH_EXPR_MAPPINGS from .nodes.math_expression import NODE_DISPLAY_NAME_MAPPINGS as MATH_EXPR_DISPLAY +from .nodes.make_image_batch import NODE_CLASS_MAPPINGS as IMAGE_BATCH_MAPPINGS +from .nodes.make_image_batch import NODE_DISPLAY_NAME_MAPPINGS as IMAGE_BATCH_DISPLAY # Combine all mappings NODE_CLASS_MAPPINGS = { @@ -45,6 +47,7 @@ NODE_CLASS_MAPPINGS = { **FACE_DETAILER_MAPPINGS, **MULTI_DETECT_MAPPINGS, **MATH_EXPR_MAPPINGS, + **IMAGE_BATCH_MAPPINGS, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -61,6 +64,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { **FACE_DETAILER_DISPLAY, **MULTI_DETECT_DISPLAY, **MATH_EXPR_DISPLAY, + **IMAGE_BATCH_DISPLAY, } WEB_DIRECTORY = "./js" diff --git a/nodes/make_image_batch.py b/nodes/make_image_batch.py new file mode 100644 index 0000000..572982e --- /dev/null +++ b/nodes/make_image_batch.py @@ -0,0 +1,59 @@ +""" +RM Make Image Batch - Combine multiple images into a single batch. +""" + +import torch + + +class RMMakeImageBatch: + """Combine up to 5 images into a single image batch.""" + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image1": ("IMAGE",), + }, + "optional": { + "image2": ("IMAGE",), + "image3": ("IMAGE",), + "image4": ("IMAGE",), + "image5": ("IMAGE",), + }, + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "process" + CATEGORY = "RMAutomation/Image" + + def process(self, image1, image2=None, image3=None, image4=None, image5=None): + images = [image1] + for img in (image2, image3, image4, image5): + if img is not None: + images.append(img) + + if len(images) == 1: + return (images[0],) + + # Match dimensions to first image + target_h = images[0].shape[1] + target_w = images[0].shape[2] + + result = [] + for img in images: + if img.shape[1] != target_h or img.shape[2] != target_w: + img = torch.nn.functional.interpolate( + img.movedim(-1, 1), size=(target_h, target_w), mode="bilinear" + ).movedim(1, -1) + result.append(img) + + return (torch.cat(result, dim=0),) + + +NODE_CLASS_MAPPINGS = { + "RMMakeImageBatch": RMMakeImageBatch, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "RMMakeImageBatch": "RM Make Image Batch", +}