| ''' |
| import os |
| from huggingface_hub import hf_hub_download |
| from huggingface_hub import login |
| |
| login(token=os.getenv("HF_TOKEN")) |
| |
| model_paths = { |
| "layer1cnn_aanan.pth": hf_hub_download(repo_id="f16sam/awss-models", filename="layer1cnn_aanan.pth"), |
| "layer2bio_00": hf_hub_download(repo_id="f16sam/awss-models", filename="layer2bio_00"), |
| "layer2bio_01": hf_hub_download(repo_id="f16sam/awss-models", filename="layer2bio_01"), |
| "layer2non_00": hf_hub_download(repo_id="f16sam/awss-models", filename="layer2non_00"), |
| "layer2non_01": hf_hub_download(repo_id="f16sam/awss-models", filename="layer2non_01"), |
| "layer3_cnn.keras": hf_hub_download(repo_id="f16sam/awss-models", filename="layer3_cnn.keras") |
| } |
| |
| |
| # Cache Folder |
| custom_cache = "/tmp/.cache" |
| os.makedirs(custom_cache, exist_ok=True) |
| os.environ["XDG_CACHE_HOME"] = custom_cache |
| os.environ["GDOWN_CACHE_DIR"] = custom_cache |
| import gdown |
| |
| # Destination folder |
| MODEL_DIR = os.path.join(os.path.dirname(__file__), ".") |
| files_to_download = { |
| "layer1cnn_aanan.pth": "1R6Up_9vyd27hdRIyGXQgi86pn42tl-bh", |
| "layer2bio_cnn.keras": "1mewJKVzhmOl_l-sVupK3OasyX_56OxjG", |
| "layer2non_cnn.keras": "1IM6Y4ZduHE4JeDgJig362n-Y1tz6YKmB", |
| "layer3_cnn.keras": "16DjttPx1f9sqWlodO5KqPyZBkpYVtVa4" |
| } |
| |
| def download_all_models(): |
| for filename, file_id in files_to_download.items(): |
| dest_path = os.path.join(MODEL_DIR, filename) |
| if not os.path.exists(dest_path): |
| print(f"Downloading {filename}...") |
| gdown.download(f"https://drive.google.com/uc?id={file_id}", dest_path, quiet=False) |
| else: |
| print(f"{filename} already exists, skipping.") |
| |
| if __name__ == "__main__": |
| download_all_models() |
| ''' |