From 311315f74c59af7233765a6910f18ef7e0f07713 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Sat, 1 Apr 2023 19:08:38 -0500 Subject: [PATCH] Add node for batching latent tensors --- nodes.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nodes.py b/nodes.py index 5c3b3a4ee..a57ea93df 100644 --- a/nodes.py +++ b/nodes.py @@ -617,6 +617,20 @@ class LatentComposite: samples_out["samples"] = s return (samples_out,) +class LatentBatch: + @classmethod + def INPUT_TYPES(s): + return {"required": { "samples": ("LATENT",), + "batch_size": ("INT", {"default": 1, "min": 1, "max": 64})}} + + RETURN_TYPES = ("LATENT",) + FUNCTION = "batch" + + CATEGORY = "latent" + + def batch(self, samples, batch_size=1): + return ({"samples":samples["samples"].repeat(batch_size, 1, 1, 1)}, ) + class LatentCrop: @classmethod def INPUT_TYPES(s): @@ -1086,6 +1100,7 @@ NODE_CLASS_MAPPINGS = { "LatentRotate": LatentRotate, "LatentFlip": LatentFlip, "LatentCrop": LatentCrop, + "LatentBatch": LatentBatch, "LoraLoader": LoraLoader, "CLIPLoader": CLIPLoader, "CLIPVisionEncode": CLIPVisionEncode,