{"record":{"id":"606107124d69e805","repo":"odysseus-dev/odysseus","slug":"no-safetensors-weights-found-for-model-in-snap","errorCode":null,"errorMessage":"No safetensors weights found for {model} in {snap}","messagePattern":"No safetensors weights found for (.+?) in (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"scripts/mlx_image_server.py","lineNumber":169,"sourceCode":"    except Exception as e:\n        raise HTTPException(\n            503,\n            \"huggingface_hub is required to download MLX image model snapshots. \"\n            \"Install the model requirements in the selected Python environment.\",\n        ) from e\n    return Path(snapshot_download(model))\n\n\ndef _weights_path(model: str) -> Path:\n    p = Path(model).expanduser()\n    if p.is_file():\n        return p\n    snap = _snapshot_path(model)\n    if snap.is_file():\n        return snap\n    candidates = sorted(snap.rglob(\"*.safetensors\"))\n    if not candidates:\n        raise HTTPException(500, f\"No safetensors weights found for {model} in {snap}\")\n    return candidates[0]\n\n\ndef _write_bridge_input_image(raw: bytes, out_path: Path) -> None:\n    try:\n        from PIL import Image\n        import io\n    except Exception as e:\n        raise HTTPException(503, \"Pillow is required for MLX image edit bridge inputs.\") from e\n    try:\n        img = Image.open(io.BytesIO(raw)).convert(\"RGBA\")\n        img.save(out_path, format=\"PNG\")\n    except Exception as e:\n        raise HTTPException(400, f\"Invalid input image: {e}\") from e\n\n\ndef _write_bridge_mask(raw: bytes, out_path: Path) -> None:\n    try:","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/scripts/mlx_image_server.py#L151-L187","documentation":"Raised by _weights_path in scripts/mlx_image_server.py after resolving a model snapshot directory that contains zero *.safetensors files (searched recursively with rglob). The LaMa/MI-GAN/DDColor bridges need a safetensors weights file; an incomplete, filtered, or wrong-repo snapshot yields HTTP 500.","triggerScenarios":"The snapshot path exists but contains no .safetensors file: interrupted snapshot_download left partial files; the repo stores weights in .bin/.gguf only; allow-patterns excluded the weights; the directory passed is a dataset or code-only repo.","commonSituations":"Disk-full or Ctrl-C during model download leaving a truncated cache; HF_HOME cache corruption; repo revision pin that points at a docs-only branch; passing a LoRA adapter directory instead of the base model.","solutions":["Delete the partial snapshot (hf cache purge or rm -rf the model dir under the HF cache) and re-download","Check the repo on the Hub actually ships .safetensors; if it only has .bin, convert or pick a safetensors variant","If snapshot_download used allow_patterns, re-run without filters so weights are fetched","Pass an explicit local path to a verified safetensors file as --model"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from pathlib import Path\nsnap = Path(snapshot_dir)\nweights = sorted(snap.rglob('*.safetensors'))\nassert weights, f'no safetensors in {snap}'","typeGuard":null,"tryCatchPattern":"try:\n    serve_model('lama')\nexcept HTTPException as e:\n    if e.status_code == 500 and 'No safetensors weights' in e.detail:\n        purge_and_redownload(model_repo); serve_model('lama')\n    else:\n        raise","preventionTips":["Verify a snapshot contains .safetensors before pointing the server at it","Purge interrupted downloads from the HF cache instead of retrying over them","Pin repo revisions that ship safetensors"],"tags":["mlx","safetensors","huggingface-cache","http-500"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}