File size: 1,001 Bytes
a863f79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
import time

os.environ.setdefault("HF_ENDPOINT", "https://hf-mirror.com")
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"

from huggingface_hub import snapshot_download

REPOS = [
    ("HuggingFaceM4/Idefics3-8B-Llama3", "Idefics3-8B-Llama3"),
    ("OpenGVLab/InternVL3-9B-Instruct", "InternVL3-9B-Instruct"),
]


def download(repo, dest):
    for attempt in range(1, 21):
        try:
            path = snapshot_download(
                repo_id=repo,
                local_dir=dest,
                max_workers=4,
                allow_patterns=["*.json", "*.safetensors", "*.txt", "*.model", "*.py", "*.jinja"],
            )
            print(f"MODEL_DONE {repo} -> {path}", flush=True)
            return
        except Exception as exc:
            print(f"RETRY {repo} attempt={attempt} {type(exc).__name__}: {str(exc)[:200]}", flush=True)
            time.sleep(20)


for repo, name in REPOS:
    download(repo, f"/repository/models/{name}")
print("ALL_DONE", flush=True)