File size: 1,316 Bytes
45d12c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import argparse

from huggingface_hub import hf_hub_download, snapshot_download


# set args for repo_id, local_dir, repo_type,

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Download a dataset or model from the Hugging Face Hub")
    parser.add_argument("--repo_id",
                        type=str,
                        help="The ID of the repository to download")
    parser.add_argument(
        "--local_dir",
        type=str,
        help="The local directory to download the repository to",
    )
    parser.add_argument(
        "--repo_type",
        type=str,
        default="model",
        help="The type of repository to download (dataset or model)",
    )
    parser.add_argument("--file_name",
                        type=str,
                        help="The file name to download")
    args = parser.parse_args()
    if args.file_name:
        hf_hub_download(
            repo_id=args.repo_id,
            filename=args.file_name,
            repo_type=args.repo_type,
            local_dir=args.local_dir,
        )
    else:
        snapshot_download(
            repo_id=args.repo_id,
            local_dir=args.local_dir,
            repo_type=args.repo_type,
            local_dir_use_symlinks=False,
            resume_download=True,
        )