Datasets:
Download code/fetch_model_aria.py from spatial-evidence-bench/SpatialEvidenceBench: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/2b2e98a86663b2fd7de0817c2c5db0d4f2e7bc83/code/fetch_model_aria.py
- Command line
-
hf download hf://datasets/spatial-evidence-bench/SpatialEvidenceBench@2b2e98a86663b2fd7de0817c2c5db0d4f2e7bc83/code/fetch_model_aria.py
-
curl -L -o fetch_model_aria.py https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/2b2e98a86663b2fd7de0817c2c5db0d4f2e7bc83/code/fetch_model_aria.py
1.88 kB
| import argparse | |
| import json | |
| import subprocess | |
| import sys | |
| import urllib.request | |
| from pathlib import Path | |
| ENDPOINT = "https://hf-mirror.com" | |
| def siblings(repo, revision="main"): | |
| url = f"{ENDPOINT}/api/models/{repo}/revision/{revision}" | |
| with urllib.request.urlopen(url, timeout=60) as resp: | |
| payload = json.loads(resp.read().decode("utf-8")) | |
| return [s["rfilename"] for s in payload.get("siblings", [])] | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--repo", required=True) | |
| parser.add_argument("--dest", required=True) | |
| parser.add_argument("--revision", default="main") | |
| args = parser.parse_args() | |
| dest = Path(args.dest) | |
| dest.mkdir(parents=True, exist_ok=True) | |
| files = siblings(args.repo, args.revision) | |
| if not files: | |
| raise RuntimeError(f"no siblings for {args.repo}") | |
| listing = dest / "urls.txt" | |
| lines = [] | |
| for name in files: | |
| lines.append(f"{ENDPOINT}/{args.repo}/resolve/{args.revision}/{name}") | |
| lines.append(f" dir={dest}") | |
| lines.append(f" out={name}") | |
| listing.write_text("\n".join(lines) + "\n", encoding="utf-8") | |
| print(f"FILES {len(files)}") | |
| proc = subprocess.run( | |
| [ | |
| "aria2c", | |
| f"--input-file={listing}", | |
| "--continue=true", | |
| "--allow-overwrite=true", | |
| "--max-connection-per-server=8", | |
| "--split=8", | |
| "--min-split-size=4M", | |
| "--retry-wait=3", | |
| "--max-tries=30", | |
| "--auto-file-renaming=false", | |
| "--allow-overwrite=false", | |
| "--console-log-level=warn", | |
| "--summary-interval=60", | |
| ], | |
| check=False, | |
| ) | |
| if proc.returncode != 0: | |
| raise SystemExit(f"aria2c failed with {proc.returncode}") | |
| print("MODEL_DONE", args.dest) | |
| if __name__ == "__main__": | |
| main() | |