odysseus-dev/odysseus · error · HTTPException

No safetensors weights found for {model} in {snap}

Error message

No safetensors weights found for {model} in {snap}

What it means

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.

Source

Thrown at scripts/mlx_image_server.py:169

    except Exception as e:
        raise HTTPException(
            503,
            "huggingface_hub is required to download MLX image model snapshots. "
            "Install the model requirements in the selected Python environment.",
        ) from e
    return Path(snapshot_download(model))


def _weights_path(model: str) -> Path:
    p = Path(model).expanduser()
    if p.is_file():
        return p
    snap = _snapshot_path(model)
    if snap.is_file():
        return snap
    candidates = sorted(snap.rglob("*.safetensors"))
    if not candidates:
        raise HTTPException(500, f"No safetensors weights found for {model} in {snap}")
    return candidates[0]


def _write_bridge_input_image(raw: bytes, out_path: Path) -> None:
    try:
        from PIL import Image
        import io
    except Exception as e:
        raise HTTPException(503, "Pillow is required for MLX image edit bridge inputs.") from e
    try:
        img = Image.open(io.BytesIO(raw)).convert("RGBA")
        img.save(out_path, format="PNG")
    except Exception as e:
        raise HTTPException(400, f"Invalid input image: {e}") from e


def _write_bridge_mask(raw: bytes, out_path: Path) -> None:
    try:

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Delete the partial snapshot (hf cache purge or rm -rf the model dir under the HF cache) and re-download
  2. Check the repo on the Hub actually ships .safetensors; if it only has .bin, convert or pick a safetensors variant
  3. If snapshot_download used allow_patterns, re-run without filters so weights are fetched
  4. Pass an explicit local path to a verified safetensors file as --model
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
snap = Path(snapshot_dir)
weights = sorted(snap.rglob('*.safetensors'))
assert weights, f'no safetensors in {snap}'

Try / catch

try:
    serve_model('lama')
except HTTPException as e:
    if e.status_code == 500 and 'No safetensors weights' in e.detail:
        purge_and_redownload(model_repo); serve_model('lama')
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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