Download weights.py from Sanket17/NewParser: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/Sanket17/NewParser/resolve/main/weights.py
- Command line
-
hf download hf://spaces/Sanket17/NewParser/weights.py
-
curl -L -o weights.py https://huggingface.co/spaces/Sanket17/NewParser/resolve/main/weights.py
1.08 kB
| 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() |