File size: 970 Bytes
199f9c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
from huggingface_hub import snapshot_download
import os
import sys
# Make sure HF_TOKEN is set in your env beforehand:
# export HF_TOKEN=your_hf_token
#get first command line argument


mode = sys.argv[1] if len(sys.argv) > 1 else "outsidephotos"


REPO_ID = "tedlasai/learn2refocus"
REPO_TYPE = "model"


checkpoints = [
    "checkpoint-200000",
]

# This is the root local directory where you want everything saved
#get path of this file
LOCAL_TRAINING_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "checkpoints")
os.makedirs(LOCAL_TRAINING_ROOT, exist_ok=True)

# Download only those folders from the repo and place them under LOCAL_TRAINING_ROOT
snapshot_download(
    repo_id=REPO_ID,
    repo_type=REPO_TYPE,
    local_dir=LOCAL_TRAINING_ROOT,
    local_dir_use_symlinks=False,
    allow_patterns=[f"{name}/*" for name in checkpoints],
    token=os.getenv("HF_TOKEN"),
)

print(f"Done! Checkpoints downloaded under: {LOCAL_TRAINING_ROOT}")