Spaces:
Sleeping
Sleeping
import os | |
import gdown | |
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) | |
# Correct file mapping with Drive file IDs and their corresponding local paths | |
files_to_download = { | |
"1hUCqZ3X8mcM-KcwWFjcsFg7PA0hUvE3k": "weights/icon_caption_florence/model.safetensors", | |
"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() | |