File size: 1,211 Bytes
3192171
326d3cc
 
 
 
 
 
 
 
3192171
326d3cc
3192171
 
326d3cc
3192171
 
 
 
 
 
 
 
 
326d3cc
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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()