odysseus-dev/odysseus · error · HTTPException

Failed to load object mask model

Error message

Failed to load object mask model {model_id}: {exc}

What it means

Wrapper error in _load_grounding_backend: instantiating the OwlViT processor/model via from_pretrained failed (exc) — corrupt checkpoint, unsupported transformers version, or device error. Chained 500 indicating the grounding backend could not be brought up and cached.

Solutions

  1. Check that the object mask model weights downloaded correctly and retry.
  2. Review server logs for the load error; reinstall the mask tools if needed.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.

Common situations: See trigger scenarios.


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/79fff035f709c5ac. Report an issue: GitHub.

Appendix: source

Thrown at routes/gallery/gallery_routes.py:123

            "Object mask tools are not installed. Install Cookbook Dependencies -> SAM mask tools.",
        ) from exc

    device = "cpu"
    try:
        if torch.cuda.is_available():
            device = "cuda"
        elif getattr(torch.backends, "mps", None) and torch.backends.mps.is_available():
            device = "mps"
    except Exception:
        device = "cpu"

    try:
        processor = OwlViTProcessor.from_pretrained(model_id)
        model = OwlViTForObjectDetection.from_pretrained(model_id)
        model.to(device)
        model.eval()
    except Exception as exc:
        raise HTTPException(500, f"Failed to load object mask model {model_id}: {exc}") from exc

    cached = {"torch": torch, "processor": processor, "model": model, "device": device, "model_id": model_id}
    _GROUNDING_STATE[model_id] = cached
    return cached


def _model_input_to_device(value, device: str, torch):
    if not hasattr(value, "to"):
        return value
    if (
        device == "mps"
        and hasattr(torch, "float64")
        and getattr(value, "dtype", None) == torch.float64
    ):
        return value.to(device=device, dtype=torch.float32)
    return value.to(device)

View on GitHub (pinned to f9235ebbf1)