Comfy-Org/ComfyUI · error · ValueError

{node_name}: input shorter edge must be at least 2 pixels; g

Error message

{node_name}: input shorter edge must be at least 2 pixels; got {upscaled_shorter_edge}.

What it means

_seedvr2_pad refuses inputs whose shorter spatial edge is smaller than 2 pixels. SeedVR2's VAE downsamples spatially by 16x, so a 1-pixel edge cannot produce a valid latent; the check fails fast instead of producing a degenerate tensor downstream.

Source

Thrown at comfy_extras/nodes_seedvr.py:105

    videos = torch.cat([videos, padding], dim=1)
    if (videos.size(1) - 1) % 4 != 0:
        raise ValueError(f"SeedVR2Preprocess failed to pad video length to 4n+1; got {videos.size(1)} frames.")
    return videos

def _seedvr2_input_shorter_edge(images, node_name):
    if images.dim() == 4:
        return min(images.shape[1], images.shape[2])
    if images.dim() == 5:
        return min(images.shape[2], images.shape[3])
    raise ValueError(
        f"{node_name}: expected 4-D or 5-D IMAGE tensor, "
        f"got shape {tuple(images.shape)}"
    )


def _seedvr2_pad(images, upscaled_shorter_edge, node_name):
    if upscaled_shorter_edge < 2:
        raise ValueError(
            f"{node_name}: input shorter edge must be at least 2 pixels; "
            f"got {upscaled_shorter_edge}."
        )
    if images.shape[-1] > 3:
        images = images[..., :3]
    if images.dim() == 4:
        # Comfy video components arrive as a 4-D IMAGE frame sequence:
        # (frames, H, W, C). SeedVR2 consumes that as one video.
        images = images.unsqueeze(0)
    elif images.dim() != 5:
        raise ValueError(
            f"{node_name}: expected 4-D or 5-D IMAGE tensor, "
            f"got shape {tuple(images.shape)}"
        )
    images = images.permute(0, 1, 4, 2, 3)

    b, t, c, h, w = images.shape
    images = images.reshape(b * t, c, h, w)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Set the input image's shorter edge to at least 2 pixels (realistically much larger: remember the VAE pads to multiples of 16).
  2. Fix the upstream resize/crop node that produced the 1-px dimension.
  3. Replace test placeholders smaller than 2 px with a realistic size, e.g. 64x64.

Example fix

# before
img = torch.zeros(1, 1, 64, 3)  # 1-px height -> error

# after
img = torch.zeros(1, 64, 64, 3)  # valid 64x64 image
Defensive patterns

Strategy: validation

Validate before calling

h, w = (images.shape[-3], images.shape[-2]) if images.dim() >= 4 else (0, 0)
assert min(h, w) >= 2, f'image too small: {h}x{w}; SeedVR2 needs shorter edge >= 2'

Type guard

def is_seedvr_sized_image(t) -> bool:
    return t.dim() in (4, 5) and min(t.shape[-3], t.shape[-2]) >= 2

Prevention

When it happens

Trigger: Feeding an IMAGE whose shorter edge (H or W for 4-D; H or W for 5-D) is 0 or 1 pixel into a SeedVR2 preprocessing/upscale node.

Common situations: A resize/crop node set to a 1-pixel dimension; an accidental [:, :1] slice; a placeholder image created with torch.zeros(1,1,1,3) for testing.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/3eb33cfe5079223b. Report an issue: GitHub.