From 46722da9f1697f7e7959db8b02461f3fb57f2274 Mon Sep 17 00:00:00 2001 From: chenxinlong Date: Tue, 26 Mar 2024 16:31:50 +0800 Subject: [PATCH] feat:support download huggingface files from a mirror site --- docker.md | 1 + modules/model_loader.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docker.md b/docker.md index 36cfa63..1939d6f 100644 --- a/docker.md +++ b/docker.md @@ -54,6 +54,7 @@ Docker specified environments are there. They are used by 'entrypoint.sh' |CMDARGS|Arguments for [entry_with_update.py](entry_with_update.py) which is called by [entrypoint.sh](entrypoint.sh)| |config_path|'config.txt' location| |config_example_path|'config_modification_tutorial.txt' location| +|HF_MIRROR| huggingface mirror site domain| You can also use the same json key names and values explained in the 'config_modification_tutorial.txt' as the environments. See examples in the [docker-compose.yml](docker-compose.yml) diff --git a/modules/model_loader.py b/modules/model_loader.py index 8ba336a..1143f75 100644 --- a/modules/model_loader.py +++ b/modules/model_loader.py @@ -14,6 +14,8 @@ def load_file_from_url( Returns the path to the downloaded file. """ + domain = os.environ.get("HF_MIRROR", "https://huggingface.co").rstrip('/') + url = str.replace(url, "https://huggingface.co", domain, 1) os.makedirs(model_dir, exist_ok=True) if not file_name: parts = urlparse(url)