File size: 1,252 Bytes
546ca60
b78ec0e
 
546ca60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b78ec0e
 
 
546ca60
b78ec0e
546ca60
 
 
 
 
b78ec0e
 
 
 
546ca60
b78ec0e
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
37
38
39
"""
Model download utilities for ZeroGPU deployment.
Actual model loading happens lazily inside @spaces.GPU in app.py.
"""

import os
from pathlib import Path


def download_phoenix_weights(output_dir: str):
    """Download Phoenix weights from HuggingFace."""
    from huggingface_hub import hf_hub_download

    os.makedirs(output_dir, exist_ok=True)

    files = {
        "flow_model.pth": "weights/flow/tenx/multi/cell/20x/discrete/flow_model.pth",
        "stats_table.npz": "statistics/tenx/multi/cell/discrete/stats_table.npz",
        "xenium_human_multi.npy": "panels/xenium_human_multi.npy",
    }

    for local_name, repo_path in files.items():
        target = Path(output_dir) / local_name
        if target.exists():
            continue
        print(f"  Downloading {local_name}...")
        hf_hub_download(
            repo_id="peng-lab/phoenix",
            filename=repo_path,
            local_dir=output_dir,
            local_dir_use_symlinks=False,
        )
        # hf_hub_download preserves subdir structure, move to flat
        downloaded = Path(output_dir) / repo_path
        if downloaded.exists() and downloaded != target:
            downloaded.rename(target)

    print(f"  Phoenix weights ready in {output_dir}")