Download code/chm/fetch.py from fnruha0921/knps-change-detection-tmp: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/fnruha0921/knps-change-detection-tmp/resolve/main/code/chm/fetch.py
- Command line
-
hf download hf://fnruha0921/knps-change-detection-tmp/code/chm/fetch.py
-
curl -L -o fetch.py https://huggingface.co/fnruha0921/knps-change-detection-tmp/resolve/main/code/chm/fetch.py
1.28 kB
| 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) | |