Spaces:
Running on T4
Running on T4
Download tools/setup_api_models.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/setup_api_models.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine@3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/setup_api_models.py
-
curl -L -o setup_api_models.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/setup_api_models.py
1.21 kB
| """Checksummed acquisition; optional public lightweight 3D model.""" | |
| import argparse | |
| from baseball_batting.config import CONFIG_ROOT | |
| from baseball_batting.resources import fetch_artifact | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--output", default="downloads") | |
| parser.add_argument("--with-3d", action="store_true") | |
| args = parser.parse_args() | |
| names = ["body_pose", "person_detector"] + (["body_pose_3d"] if args.with_3d else []) | |
| for name in names: | |
| record = fetch_artifact(name, CONFIG_ROOT / "resources.yaml", args.output) | |
| # Public .onnx downloads can have arbitrary filenames; worker paths are | |
| # fixed, just like extracted ZIP artifacts. | |
| from pathlib import Path | |
| from baseball_batting.storage import atomic_json | |
| model = Path(args.output)/name/"model.onnx" | |
| if Path(record["artifact_path"]).resolve() != model.resolve(): | |
| Path(record["artifact_path"]).replace(model) | |
| record["artifact_path"] = str(model.resolve()) | |
| atomic_json(model.parent/"resource.json", record) | |
| print(f"{name}: verified {record['sha256']}", flush=True) | |
| if __name__ == "__main__": | |
| main() | |