PepPA / scripts /download_models.py
pranamanam's picture
Upload 97 files
98bde72 verified
Raw
History Blame Contribute Delete
877 Bytes
"""Download selected pinned artifacts. Does not download weights by default."""
import argparse,json
from pathlib import Path
def main():
p=argparse.ArgumentParser();p.add_argument('component');p.add_argument('--destination',required=True);p.add_argument('--weights',action='store_true');a=p.parse_args()
from huggingface_hub import snapshot_download
registry=json.loads((Path(__file__).resolve().parents[1]/'configs/model_registry.json').read_text())
x=registry[a.component]
if not x.get('revision'):raise ValueError('resolve and freeze a revision before downloading this component')
snapshot_download(repo_id=x['repo_id'],repo_type=x.get('repo_type','model'),revision=x['revision'],local_dir=a.destination,
allow_patterns=None if a.weights else ['*.py','*.json','*.yaml','*.yml','*.txt','*.md','*.toml','*.sh'])
if __name__=='__main__':main()