HuggingFace Downloader

HuggingFace Downloader

Code pieces for downloading models or datasets from Hugging Face.

Install

1
2
pip install huggingface_hub
huggingface-cli --help

downloader.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
from huggingface_hub import snapshot_download

repo_id_list=[
# samples
"openai/clip-vit-base-patch32"
]

# download
for repo_id in repo_id_list:
print("Start Downloading for repo {}".format(repo_id))
local_dir = snapshot_download(repo_id=repo_id,
repo_type='model',
local_dir=os.path.join("Models",repo_id) ,
local_dir_use_symlinks=False,
cache_dir=".cache",
resume_download=True,
endpoint="https://hf-mirror.com",
use_auth_token="hf_*************")
print(f"File downloaded to {local_dir}")

Run

1
python downloader.py
Author

Breynald

Posted on

2024-09-22

Updated on

2025-05-28

Licensed under

Comments