Create weights.py
Browse files- weights.py +27 -0
weights.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gdown
|
3 |
+
import torch
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
def download_weights():
|
7 |
+
# Create directories if they don't exist
|
8 |
+
Path("weights/icon_detect").mkdir(parents=True, exist_ok=True)
|
9 |
+
Path("weights/icon_caption_florence").mkdir(parents=True, exist_ok=True)
|
10 |
+
|
11 |
+
# Google Drive file IDs and their corresponding local paths
|
12 |
+
files_to_download = {
|
13 |
+
"https://drive.google.com/file/d/1hUCqZ3X8mcM-KcwWFjcsFg7PA0hUvE3k": "weights/icon_caption_florence/model.safetensors",
|
14 |
+
"https://drive.google.com/file/d/1p-Y7rd0FfjNnv_jewCi7ZjXH3T-qtyAa": "weights/icon_detect/best.pt"
|
15 |
+
}
|
16 |
+
|
17 |
+
for file_id, output_path in files_to_download.items():
|
18 |
+
if not os.path.exists(output_path):
|
19 |
+
print(f"Downloading {output_path}...")
|
20 |
+
url = f"https://drive.google.com/uc?id={file_id}"
|
21 |
+
gdown.download(url, output_path, quiet=False)
|
22 |
+
print(f"Downloaded {output_path}")
|
23 |
+
else:
|
24 |
+
print(f"File {output_path} already exists, skipping download")
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
download_weights()
|