Add Batch Images, Batch Masks, and Batch Latents nodes with Autogrow, deprecate old Batch Images + LatentBatch nodes
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled

This commit is contained in:
Jedrzej Kosinski 2025-12-29 18:12:22 -08:00
parent 6c3b7f95bc
commit d564ef6832
3 changed files with 65 additions and 0 deletions

View File

@ -255,6 +255,7 @@ class LatentBatch(io.ComfyNode):
return io.Schema( return io.Schema(
node_id="LatentBatch", node_id="LatentBatch",
category="latent/batch", category="latent/batch",
is_deprecated=True,
inputs=[ inputs=[
io.Latent.Input("samples1"), io.Latent.Input("samples1"),
io.Latent.Input("samples2"), io.Latent.Input("samples2"),

View File

@ -498,6 +498,66 @@ def batch_latents(latents: list[dict[str, torch.Tensor]]) -> dict[str, torch.Ten
samples_out["samples"] = torch.cat(tensors, dim=0) samples_out["samples"] = torch.cat(tensors, dim=0)
return samples_out return samples_out
class BatchImagesNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Image.Input("image"), prefix="image", min=2, max=50)
return io.Schema(
node_id="BatchImagesNode",
display_name="Batch Images",
category="image",
inputs=[
io.Autogrow.Input("images", template=autogrow_template)
],
outputs=[
io.Image.Output()
]
)
@classmethod
def execute(cls, images: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_images(list(images.values())))
class BatchMasksNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Mask.Input("mask"), prefix="mask", min=2, max=50)
return io.Schema(
node_id="BatchMasksNode",
display_name="Batch Masks",
category="mask",
inputs=[
io.Autogrow.Input("masks", template=autogrow_template)
],
outputs=[
io.Mask.Output()
]
)
@classmethod
def execute(cls, masks: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_masks(list(masks.values())))
class BatchLatentsNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Latent.Input("latent"), prefix="latent", min=2, max=50)
return io.Schema(
node_id="BatchLatentsNode",
display_name="Batch Latents",
category="latent",
inputs=[
io.Autogrow.Input("latents", template=autogrow_template)
],
outputs=[
io.Latent.Output()
]
)
@classmethod
def execute(cls, latents: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_latents(list(latents.values())))
class BatchImagesMasksLatentsNode(io.ComfyNode): class BatchImagesMasksLatentsNode(io.ComfyNode):
@classmethod @classmethod
def define_schema(cls): def define_schema(cls):
@ -542,6 +602,9 @@ class PostProcessingExtension(ComfyExtension):
Sharpen, Sharpen,
ImageScaleToTotalPixels, ImageScaleToTotalPixels,
ResizeImageMaskNode, ResizeImageMaskNode,
BatchImagesNode,
BatchMasksNode,
BatchLatentsNode,
# BatchImagesMasksLatentsNode, # BatchImagesMasksLatentsNode,
] ]

View File

@ -1863,6 +1863,7 @@ class ImageBatch:
FUNCTION = "batch" FUNCTION = "batch"
CATEGORY = "image" CATEGORY = "image"
DEPRECATED = True
def batch(self, image1, image2): def batch(self, image1, image2):
if image1.shape[-1] != image2.shape[-1]: if image1.shape[-1] != image2.shape[-1]: