invoke-ai/InvokeAI · error

Unsupported resize_mode: '{resize_mode}'.

Error message

Unsupported resize_mode: '{resize_mode}'.

What it means

prepare_control_image only supports the defined ResizeMode enum values (e.g. RESIZE, CROP, FIT, etc.); any other value reaches the final else branch and raises ValueError. The resize mode determines how the control image is resized/cropped to the target dimensions before inference.

Source

Thrown at invokeai/app/util/controlnet_utils.py:423

        nimage = nimage[None, :]
        nimage = np.concatenate([nimage], axis=0)
        # normalizing RGB values to [0,1] range (in PIL.Image they are [0-255])
        nimage = np.array(nimage).astype(np.float32) / 255.0
        nimage = nimage.transpose(0, 3, 1, 2)
        timage = torch.from_numpy(nimage)

    # use fancy lvmin controlnet resizing
    elif resize_mode == "just_resize" or resize_mode == "crop_resize" or resize_mode == "fill_resize":
        nimage = np.array(image)
        timage, nimage = np_img_resize(
            np_img=nimage,
            resize_mode=resize_mode,
            h=height,
            w=width,
            device=torch.device(device),
        )
    else:
        raise ValueError(f"Unsupported resize_mode: '{resize_mode}'.")

    if timage.shape[1] < num_channels or num_channels <= 0:
        raise ValueError(f"Cannot achieve the target of num_channels={num_channels}.")
    timage = timage[:, :num_channels, :, :]

    timage = timage.to(device=device, dtype=dtype)
    cfg_injection = control_mode == "more_control" or control_mode == "unbalanced"
    if do_classifier_free_guidance and not cfg_injection:
        timage = torch.cat([timage] * 2)
    return timage

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass a valid ResizeMode enum member (e.g. ResizeMode.RESIZE) instead of a raw string/int
  2. Coerce incoming values: ResizeMode(value) in a try/except before calling, defaulting to ResizeMode.RESIZE
  3. If upgrading, migrate saved workflows whose resize_mode values match the old enum naming

Example fix

// before
prep_control_data(..., resize_mode="just_resize", ...)
// after
from invokeai.app.invocations.constants import ResizeMode
prep_control_data(..., resize_mode=ResizeMode.RESIZE, ...)  # or ResizeMode(value) validated
Defensive patterns

Strategy: validation

Validate before calling

from invokeai.app.invocations.constants import ResizeMode
def coerce_resize_mode(v) -> ResizeMode:
    try:
        return ResizeMode(v)
    except ValueError:
        return ResizeMode.RESIZE

Type guard

def is_resize_mode(v: object) -> bool:
    try:
        ResizeMode(v)
        return True
    except ValueError:
        return False

Try / catch

try:
    image = prepare_control_image(..., resize_mode=resize_mode)
except ValueError as e:
    if "Unsupported resize_mode" in str(e):
        image = prepare_control_image(..., resize_mode=ResizeMode.RESIZE)
    else:
        raise

Prevention

When it happens

Trigger: Calling prepare_control_image with a raw string or arbitrary int instead of a ResizeMode enum member, or a ResizeMode added in a newer version but passed through deserialization the code path doesn't handle.

Common situations: Old saved workflows/settings containing a resize_mode value removed or renamed across InvokeAI versions; API clients sending numeric codes; config files edited by hand.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/654b835cd31a79a5. Report an issue: GitHub.