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)