From 1347c64a751b5cf1912b66bc9430b718149e59fe Mon Sep 17 00:00:00 2001 From: Nourepide Date: Tue, 28 Nov 2023 07:40:04 +0300 Subject: [PATCH] Add ImageBatchCopy node. --- modules/ImageBatch.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/ImageBatch.py b/modules/ImageBatch.py index 4203915..0a94a60 100644 --- a/modules/ImageBatch.py +++ b/modules/ImageBatch.py @@ -26,11 +26,44 @@ class ImageBatchGet: def node(self, images, index): batch = images.shape[0] - index = min(batch, index - 1) + index = min(batch, index) - 1 return (images[index].unsqueeze(0),) +class ImageBatchCopy: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "images": ("IMAGE",), + "index": ("INT", { + "default": 1, + "min": 1, + "step": 1 + }), + "quantity": ("INT", { + "default": 1, + "min": 2, + "step": 1 + }), + }, + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "node" + CATEGORY = "image/batch" + + def node(self, images, index, quantity): + batch = images.shape[0] + index = min(batch, index) - 1 + + return (images[index].repeat(quantity, 1, 1, 1),) + + class ImageBatchRemove: def __init__(self): pass @@ -158,6 +191,7 @@ class ImageBatchPermute: NODE_CLASS_MAPPINGS = { "ImageBatchGet": ImageBatchGet, + "ImageBatchCopy": ImageBatchCopy, "ImageBatchRemove": ImageBatchRemove, "ImageBatchFork": ImageBatchFork, "ImageBatchJoin": ImageBatchJoin,