{"record":{"id":"50d25f9f6e78965b","repo":"odysseus-dev/odysseus","slug":"failed-to-load-sam-model-model-id-exc","errorCode":null,"errorMessage":"Failed to load SAM model {model_id}: {exc}","messagePattern":"Failed to load SAM model (.+?): (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":87,"sourceCode":"            \"SAM mask tools are not installed. Install Cookbook Dependencies -> SAM mask tools.\",\n        ) from exc\n\n    device = \"cpu\"\n    try:\n        if torch.cuda.is_available():\n            device = \"cuda\"\n        elif getattr(torch.backends, \"mps\", None) and torch.backends.mps.is_available():\n            device = \"mps\"\n    except Exception:\n        device = \"cpu\"\n\n    try:\n        processor = SamProcessor.from_pretrained(model_id)\n        model = SamModel.from_pretrained(model_id)\n        model.to(device)\n        model.eval()\n    except Exception as exc:\n        raise HTTPException(500, f\"Failed to load SAM model {model_id}: {exc}\") from exc\n\n    cached = {\"torch\": torch, \"processor\": processor, \"model\": model, \"device\": device, \"model_id\": model_id}\n    _SAM_STATE[model_id] = cached\n    return cached\n\n\ndef _load_grounding_backend():\n    model_id = os.getenv(\"ODYSSEUS_GROUNDING_MODEL\", \"google/owlvit-base-patch32\")\n    cached = _GROUNDING_STATE.get(model_id)\n    if cached:\n        return cached\n    try:\n        import torch\n        from transformers import OwlViTForObjectDetection, OwlViTProcessor\n    except Exception as exc:\n        raise HTTPException(\n            501,\n            \"Object mask tools are not installed. Install Cookbook Dependencies -> SAM mask tools.\",","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L69-L105","documentation":"Error \"Failed to load SAM model {model_id}: {exc}\" thrown in odysseus-dev/odysseus.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","solutions":["Check that the SAM model weights downloaded correctly and retry.","Review server logs for the load error; reinstall the SAM mask tools if needed."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}