ruvnet/RuView · error · SystemExit
weights file not found: {weights_path}
Error message
weights file not found: {weights_path} What it means
scripts/export-onnx.py converts the PoseNet safetensors checkpoint to ONNX. It takes the weights path from sys.argv[1], defaulting to ./pose_v1.safetensors relative to the current working directory, and raises SystemExit with this message when the path does not exist. In this repository the trained checkpoint actually lives at v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors, so running the script from the repo root without arguments fails.
Source
Thrown at scripts/export-onnx.py:72
if name == "__metadata__":
continue
start, end = meta["data_offsets"]
shape = meta["shape"]
dtype = meta["dtype"]
assert dtype == "F32", f"unsupported dtype {dtype} for {name}"
f.seek(8 + header_len + start)
buf = f.read(end - start)
arr = np.frombuffer(buf, dtype=np.float32).copy().reshape(shape)
out[name] = torch.from_numpy(arr)
return out
def main() -> None:
weights_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("pose_v1.safetensors")
out_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("pose_v1.onnx")
if not weights_path.exists():
raise SystemExit(f"weights file not found: {weights_path}")
print(f"reading {weights_path}")
tensors = load_safetensors(weights_path)
print(f" found {len(tensors)} tensors: {sorted(tensors.keys())}")
model = PoseNet()
# Map safetensors names (enc.c1.weight, head.fc1.weight, ...) to module params
mapping = {
"enc.c1.weight": "c1.weight",
"enc.c1.bias": "c1.bias",
"enc.c2.weight": "c2.weight",
"enc.c2.bias": "c2.bias",
"enc.c3.weight": "c3.weight",
"enc.c3.bias": "c3.bias",
"head.fc1.weight": "fc1.weight",
"head.fc1.bias": "fc1.bias",
"head.fc2.weight": "fc2.weight",
"head.fc2.bias": "fc2.bias",View on GitHub (pinned to 4685618388)
Solutions
- Pass the checkpoint explicitly: `python scripts/export-onnx.py v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors pose_v1.onnx`
- Or run the script from the directory containing the weights so the default resolves
- Locate the file first: `find . -name 'pose_v1.safetensors'` if you are unsure where the artifact is
- If no checkpoint exists, produce or fetch the training artifact before exporting (the script cannot start from random init)
Example fix
# before python scripts/export-onnx.py # SystemExit: weights file not found: pose_v1.safetensors # after python scripts/export-onnx.py \ v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors \ v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.onnx
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
weights = Path("v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors")
assert weights.exists(), f"checkpoint missing: {weights}" Prevention
- Always pass the weights path explicitly instead of relying on the cwd-relative default
- In CI/artifact scripts, resolve the checkpoint from the repo root, not the working directory
- Fail fast with your own exists() check so the message names the expected artifact location
When it happens
Trigger: Running `python scripts/export-onnx.py` from a directory that does not contain pose_v1.safetensors; passing a relative weights path from a different cwd; typo or stale path after the artifacts moved.
Common situations: Executing the script from the repo root instead of the artifacts directory; a fresh clone where the training artifact has not been produced/downloaded yet; CI job that assumes cwd-relative defaults.
Related errors
- manifest not found: {MANIFEST_PATH}
- Calibration bundle {path} missing key {key!r}
- manifest is not valid JSON: {e}
- manifest must be an object with a 'markers' array
- duplicate marker ids: {sorted(dupes)}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/61d08c6620fdce7a.
Report an issue: GitHub.