Spaces:
Running on Zero
Running on Zero
Download download_checkpoints.py from hugging-apps/mmdiff: direct link, hf CLI and curl.
- Browser
- Download file 982 Bytes
-
https://huggingface.co/spaces/hugging-apps/mmdiff/resolve/1a20aec05fb13049750a9b1bf697397a284ee687/download_checkpoints.py
- Command line
-
hf download hf://spaces/hugging-apps/mmdiff@1a20aec05fb13049750a9b1bf697397a284ee687/download_checkpoints.py
-
curl -L -o download_checkpoints.py https://huggingface.co/spaces/hugging-apps/mmdiff/resolve/1a20aec05fb13049750a9b1bf697397a284ee687/download_checkpoints.py
982 Bytes
| """Download model checkpoints from yagmurakarken/mmdiff at Space startup.""" | |
| import os | |
| from huggingface_hub import hf_hub_download | |
| CHECKPOINT_DIR = "/tmp/checkpoints" | |
| MODEL_REPO = "yagmurakarken/mmdiff" | |
| CHECKPOINT_FILES = ["duts_saliency.ckpt", "nyu_depth.ckpt", "pascal_segmentation.ckpt"] | |
| def download_all(): | |
| os.makedirs(CHECKPOINT_DIR, exist_ok=True) | |
| token = os.environ.get("HF_TOKEN") | |
| for fname in CHECKPOINT_FILES: | |
| path = os.path.join(CHECKPOINT_DIR, fname) | |
| if not os.path.exists(path): | |
| print(f"[DOWNLOAD] {fname} ...") | |
| downloaded = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=fname, | |
| repo_type="model", | |
| local_dir=CHECKPOINT_DIR, | |
| token=token, | |
| ) | |
| print(f"[DOWNLOAD] {fname} -> {downloaded}") | |
| else: | |
| print(f"[DOWNLOAD] {fname} already exists at {path}") | |
| if __name__ == "__main__": | |
| download_all() |