Model downloader: Take HF_ENDPOINT in consideration (#5571)

This commit is contained in:
zaypen 2024-04-12 05:28:10 +08:00 committed by GitHub
parent 70c637bf90
commit a90509d82e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,7 +21,7 @@ import tqdm
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from tqdm.contrib.concurrent import thread_map from tqdm.contrib.concurrent import thread_map
base = "https://huggingface.co" base = os.environ.get("HF_ENDPOINT") or "https://huggingface.co"
class ModelDownloader: class ModelDownloader:
@ -112,12 +112,12 @@ class ModelDownloader:
sha256.append([fname, dict[i]['lfs']['oid']]) sha256.append([fname, dict[i]['lfs']['oid']])
if is_text: if is_text:
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}") links.append(f"{base}/{model}/resolve/{branch}/{fname}")
classifications.append('text') classifications.append('text')
continue continue
if not text_only: if not text_only:
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}") links.append(f"{base}/{model}/resolve/{branch}/{fname}")
if is_safetensors: if is_safetensors:
has_safetensors = True has_safetensors = True
classifications.append('safetensors') classifications.append('safetensors')