{"record":{"id":"f972be2fd37815a1","repo":"odysseus-dev/odysseus","slug":"sam-mask-tools-are-not-installed-install-cookbook","errorCode":null,"errorMessage":"SAM mask tools are not installed. Install Cookbook Dependencies -> SAM mask tools.","messagePattern":"SAM mask tools are not installed\\. Install Cookbook Dependencies -> SAM mask tools\\.","errorType":"http","errorClass":"HTTPException","httpStatus":501,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":67,"sourceCode":"        raise HTTPException(400, \"Invalid image\") from exc\n\n\ndef _pil_image_to_b64(img, *, fmt: str = \"PNG\") -> str:\n    buf = io.BytesIO()\n    img.save(buf, format=fmt)\n    return base64.b64encode(buf.getvalue()).decode(\"ascii\")\n\n\ndef _load_sam_backend():\n    model_id = os.getenv(\"ODYSSEUS_SAM_MODEL\", \"facebook/sam-vit-base\")\n    cached = _SAM_STATE.get(model_id)\n    if cached:\n        return cached\n    try:\n        import torch\n        from transformers import SamModel, SamProcessor\n    except Exception as exc:\n        raise HTTPException(\n            501,\n            \"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()","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L49-L85","documentation":"Error \"SAM mask tools are not installed. Install Cookbook Dependencies -> SAM mask tools.\" 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":["Install the SAM mask tools via Cookbook Dependencies → SAM mask tools.","Restart the server after installing the dependencies."],"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"}