File size: 1,076 Bytes
3ea1312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import gdown
import torch
from pathlib import Path

def download_weights():
    # Create directories if they don't exist
    Path("weights/icon_detect").mkdir(parents=True, exist_ok=True)
    Path("weights/icon_caption_florence").mkdir(parents=True, exist_ok=True)
    
    # Google Drive file IDs and their corresponding local paths
    files_to_download = {
        "https://drive.google.com/file/d/1hUCqZ3X8mcM-KcwWFjcsFg7PA0hUvE3k": "weights/icon_caption_florence/model.safetensors",
        "https://drive.google.com/file/d/1p-Y7rd0FfjNnv_jewCi7ZjXH3T-qtyAa": "weights/icon_detect/best.pt"
    }
    
    for file_id, output_path in files_to_download.items():
        if not os.path.exists(output_path):
            print(f"Downloading {output_path}...")
            url = f"https://drive.google.com/uc?id={file_id}"
            gdown.download(url, output_path, quiet=False)
            print(f"Downloaded {output_path}")
        else:
            print(f"File {output_path} already exists, skipping download")

if __name__ == "__main__":
    download_weights()