Nodes/comfyui_transit_node/CYAI 图像合并 (多图参考)
ComfyUI Node

CYAI 图像合并 (多图参考)

Killing the 'sizes of tensors must match' error

By Gin3601·Created 11 days ago·Updated 9 days ago· 0
CYAI 图像合并 (多图参考)
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • image_6
  • image_7
  • image_8
  • image_9
  • images
◄max_side1024►

This is the least glamorous node in the pack and the one you'll actually need first. In ComfyUI an IMAGE is a stacked tensor, and a batch is just more of them along dimension zero - which means every image in that batch has to be exactly the same height and width. Wire two Load Image nodes into anything that expects a batch and the torch.cat underneath dies with Sizes of tensors must match except in dimension 0. Nine separate loaders with nine different sources is exactly the situation the Seedance video node's reference_images port puts you in.

So: nine optional IMAGE inputs, one IMAGE output. Connect what you have, leave the rest empty.

What it does to your pixels

It doesn't just concatenate. Each incoming image gets resized so its long edge equals max_side (default 1024), pasted onto a max_side × max_side white canvas, and centred - then the squares are stacked. That's why the sizes agree and why the node can't fail on shape. The white fill isn't decoration: RGBA inputs are composited onto white first, specifically so transparent pixels don't turn into black fringes once the frames are JPEG-encoded for the API. A black bar around every reference image has a real habit of bleeding into what the model generates.

One behaviour worth knowing: a single input port accepts a batch. If image_1 is wired from a loader giving you four frames, you get four references out of that one port, flattened in order. Inputs are processed image_1 through image_9 in sequence, so the order of your references is the order of your ports - and reference order does influence which image the model leans on.

Nine is the ceiling because Seedance 2's multi-reference input tops out at nine images. Wire more and you don't get a warning; you just can't. In practice one to four references is what the model handles well, so the extra ports are headroom rather than an invitation.

In a real graph

[Load Image] ─┐
              ├→ [CYAI 图像合并] ──images──→ [CYAI Seedance 视频生成].reference_images
[Load Image] ─┘

Then set ratio on the video node to whatever you want (any value is legal here - the adaptive requirement only applies to first/last-frame mode), and if your references are real faces, turn on upload_images so the node converts them to assets before submitting.

If you're building a character, feed the merge node a turnaround sheet rather than three unrelated photos: multi-view sheets are still the cheapest way to hand a model the back of someone's head, and edit models have made generating one a single pass instead of a Flux-plus-ControlNet-plus-LoRA assembly job.

Installing it

It's part of the pack, so installing the pack installs it:

cd ComfyUI/custom_nodes
git clone https://github.com/Gin3601/comfyui_transit_node.git

Restart, then find it under the CYAI/Seedance category - yes, the merge node lives in the video category, not with the image-gen node, which is mildly confusing. Manager users: search CYAI Seedance and take the whole pack. No dependencies, nothing to download.

Where people get burned

The padding changes your aspect ratio and the model can see it. A 21:9 screenshot fed in becomes a square with wide white bars, and the model interprets those bars as part of the frame - expect letterboxing to sneak into compositions, or for the model to treat the padding as negative space. If the geometry matters, crop or outpaint to a square before this node rather than letting it pad. max_side above 1024 also just makes the request bigger for no real gain, since the video node downscales to image_max_side (1024) before encoding anyway.

Don't add it when you don't need it. One image goes straight into first_frame or reference_images; nothing needs merging. The node is for combining sources.

Nothing connected raises "至少连接一张图像". That one's honest, at least.

The upload behaviour moved. Older versions of this node did the asset upload itself. It no longer does - the source comment says so explicitly. All the upload logic now lives behind the video node's upload_images toggle, so if you're following a workflow from a few months ago and this node has settings for an image host, you're looking at a stale graph.

CategoryCYAI/Seedance

Inputs (10)

NameTypeDefaultDescription
image_1optIMAGE第 1 张参考图(按顺序拼接)
image_2optIMAGE第 2 张参考图(按顺序拼接)
image_3optIMAGE第 3 张参考图(按顺序拼接)
image_4optIMAGE第 4 张参考图(按顺序拼接)
image_5optIMAGE第 5 张参考图(按顺序拼接)
image_6optIMAGE第 6 张参考图(按顺序拼接)
image_7optIMAGE第 7 张参考图(按顺序拼接)
image_8optIMAGE第 8 张参考图(按顺序拼接)
image_9optIMAGE第 9 张参考图(按顺序拼接)
max_sideoptINT1024256–4096统一缩放边长(正方形、白底居中填充)。多图尺寸/比例不一致时,靠它把每张图归一成同尺寸再拼接

Outputs (1)

NameTypeDescription
imagesIMAGE合并后的图像 batch(按 image_1 → image_9 顺序)