File size: 1,282 Bytes
a1da287 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import os, shutil
from huggingface_hub import hf_hub_download
t = os.environ["HFT"]; r = "fnruha0921/knps-change-detection-tmp"; M = "/workspace/pkg/assets/model"
os.makedirs(M, exist_ok=True); os.makedirs("/workspace/prep", exist_ok=True)
for src, dst in ({} if os.path.exists(f"{M}/siam_k3.pt") else {"soup_all": "unet_synth", "siam_v2": "siam_v2", "sk0": "siam_k0", "sk1": "siam_k1", "sk2": "siam_k2", "sk3": "siam_k3"}).items():
shutil.move(hf_hub_download(r, f"models/{src}.pt", local_dir="/workspace/hfd", token=t), f"{M}/{dst}.pt"); print("got", src, flush=True)
from transformers import AutoImageProcessor, AutoModelForDepthEstimation
for repo in ("WEO-SAS/chm-meta-v2",): # ungated redistribution of facebook/dinov3-vitl16-chmv2-dpt-head (DINOv3 License)
AutoImageProcessor.from_pretrained(repo, token=t).save_pretrained("/workspace/pkg/assets/chmv2")
AutoModelForDepthEstimation.from_pretrained(repo, token=t).save_pretrained("/workspace/pkg/assets/chmv2")
print("got chmv2", repo, flush=True)
for n in ["flair_x", "flair_y", "flair2_x", "flair2_y", "tcd_x", "tcd_y"]:
shutil.move(hf_hub_download(r, f"data/prep/{n}.npy", local_dir="/workspace/hfd", token=t), f"/workspace/prep/{n}.npy"); print("got", n, flush=True)
print("FETCH_DONE", flush=True)
|