invoke-ai/InvokeAI · error · HTTPException

Admin privileges required

Error message

Admin privileges required

What it means

SpandrelModelLoader.load_from_file wraps spandrel's ModelLoader and only supports ImageModelDescriptor (image-to-image models). If spandrel loads the file into a different descriptor type the ValueError is raised naming the loaded type.

Source

Thrown at invokeai/app/api/auth_dependencies.py:237

) -> TokenData:
    """Require admin role for the current user.

    Stays `async def`, unlike the dependencies it builds on: this only reads a field off the
    already-resolved token data. Declaring it `def` would buy a threadpool round-trip per admin
    request and nothing else. The `users.get` that can block lives in `get_current_user`, which
    is synchronous for that reason.

    Args:
        current_user: The current authenticated user's token data

    Returns:
        The token data if user is an admin

    Raises:
        HTTPException: If user does not have admin privileges (403 Forbidden)
    """
    if not current_user.is_admin:
        raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Admin privileges required")
    return current_user


def require_admin_or_default(
    current_user: Annotated[TokenData, Depends(get_current_user_or_default)],
) -> TokenData:
    """Require admin role for the current user, or return default system admin in single-user mode.

    `async def` for the same reason as `require_admin`: it does no blocking work of its own.

    This dependency is useful for admin-only endpoints that should work in both single-user and multiuser modes.

    When multiuser mode is disabled (default), this always returns a system user with admin privileges.
    When multiuser mode is enabled, this validates that the authenticated user has admin privileges.

    Args:
        current_user: The current authenticated user's token data (or default system user)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use an image-to-image model (ESRGAN, Real-ESRGAN, SwinIR, GFPGAN, etc.) that spandrel exposes as ImageModelDescriptor
  2. Check the model file: replace video/unsupported models with a supported image upscaler
  3. Upgrade or pin the spandrel dependency so the architecture is recognized as an image model
  4. Verify the .pth isn't corrupted or a checkpoint of the wrong kind by loading it with spandrel's ModelLoader directly

Example fix

// before
model = SpandrelImageToImageModel.load_from_file("video_sr_model.pth")  # VideoModelDescriptor
// after
model = SpandrelImageToImageModel.load_from_file("4x_NMKD-Superscale.pth")  # ImageModelDescriptor
Defensive patterns

Strategy: type-guard

Validate before calling

from spandrel import ImageModelDescriptor
from spandrel_extra_arches import ExtraModelLoader  # optional arches
m = ModelLoader().load_from_file(path)
assert isinstance(m, ImageModelDescriptor), type(m)

Type guard

from spandrel import ImageModelDescriptor
def is_image_to_image_model(model) -> bool:
    return isinstance(model, ImageModelDescriptor)

Try / catch

try:
    model = SpandrelImageToImageModel.load_from_file(path)
except ValueError as e:
    if "ImageModelDescriptor" in str(e):
        raise RuntimeError(f"{path} is not an image-to-image model; pick a supported upscaler") from e
    raise

Prevention

When it happens

Trigger: Loading a spandrel model file that is a VideoModelDescriptor (video SR), an unsupported architecture that spandrel wraps differently, or a corrupted/non-standard ESRGAN/ONNX file that yields a non-image descriptor.

Common situations: Dropping a video-upscaler or unsupported architecture .pth into InvokeAI's models directory, installing a spandrel version that changed descriptor classes, or selecting the wrong model file in the UI for the upscaling node.

Related errors


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