Files
geointel/scripts/inspect_torch_checkpoint.py
T
Jens faeb58ef6d
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
Initial public release
2026-08-31 21:56:53 +02:00

29 lines
720 B
Python

#!/usr/bin/env python3
"""Print non-tensor provenance metadata from a PyTorch checkpoint."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("checkpoint", type=Path)
args = parser.parse_args()
import torch
checkpoint = torch.load(args.checkpoint, map_location="cpu", weights_only=True)
payload = {
key: checkpoint.get(key)
for key in ("date", "version", "license", "docs", "train_args")
if checkpoint.get(key) is not None
}
print(json.dumps(payload, indent=2, default=str))
return 0
if __name__ == "__main__":
raise SystemExit(main())