Download code/scripts/download_core_parallel.py from CollinMa/nextgpt-chapter6-report: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/download_core_parallel.py
- Command line
-
hf download hf://spaces/CollinMa/nextgpt-chapter6-report/code/scripts/download_core_parallel.py
-
curl -L -o download_core_parallel.py https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/download_core_parallel.py
1.36 kB
| """Use an anonymous mirror transport; hashes come from the official HF API.""" | |
| import fnmatch | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| from settings import MODELS, WEIGHTS | |
| from huggingface_hub import HfApi | |
| from range_download import download | |
| from download_core import download_imagebind | |
| if __name__ == "__main__": | |
| api = HfApi() | |
| for key, destination, patterns in [ | |
| ("nextgpt", WEIGHTS / "nextgpt", ["*.json", "*.model", "pytorch_model.pt"]), | |
| ("llama", WEIGHTS / "sources" / "llama", ["*.json", "*.model", "*.safetensors"]), | |
| ("vicuna_delta", WEIGHTS / "sources" / "vicuna_delta", ["*.json", "*.model", "pytorch_model*.bin"]), | |
| ]: | |
| repo, revision = MODELS[key] | |
| info = api.model_info(repo, revision=revision, files_metadata=True) | |
| for file in info.siblings: | |
| if not any(fnmatch.fnmatch(file.rfilename, pattern) for pattern in patterns): | |
| continue | |
| lfs = file.lfs | |
| download(f"https://hf-mirror.com/{repo}/resolve/{revision}/{file.rfilename}", | |
| destination / file.rfilename, file.size, | |
| sha256=lfs.sha256 if lfs else None, git_sha1=file.blob_id if not lfs else None) | |
| download_imagebind() | |
| print("Core model downloads verified.", flush=True) | |