Delete scripts/old-download_ckpts.py
Browse files
scripts/old-download_ckpts.py
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
import argparse
|
| 2 |
-
import yaml
|
| 3 |
-
import os
|
| 4 |
-
import requests
|
| 5 |
-
from huggingface_hub import snapshot_download
|
| 6 |
-
|
| 7 |
-
def load_config(config_path):
|
| 8 |
-
with open(config_path, 'r') as file:
|
| 9 |
-
return yaml.safe_load(file)
|
| 10 |
-
|
| 11 |
-
def download_model(model_id, local_dir, platform, url=None):
|
| 12 |
-
# Ensure the local directory exists
|
| 13 |
-
os.makedirs(local_dir, exist_ok=True)
|
| 14 |
-
|
| 15 |
-
if platform == "HuggingFace":
|
| 16 |
-
print(f"Downloading model {model_id} from HuggingFace to {local_dir}")
|
| 17 |
-
snapshot_download(
|
| 18 |
-
repo_id=model_id,
|
| 19 |
-
local_dir=local_dir,
|
| 20 |
-
local_dir_use_symlinks=False,
|
| 21 |
-
allow_patterns=["*.pth", "*.bin", "*.json"], # Common model file extensions
|
| 22 |
-
ignore_patterns=["*.md", "*.txt"], # Ignore non-model files
|
| 23 |
-
)
|
| 24 |
-
print(f"Successfully downloaded {model_id} to {local_dir}")
|
| 25 |
-
elif platform == "GitHub":
|
| 26 |
-
if not url:
|
| 27 |
-
raise ValueError(f"No URL provided for GitHub model: {model_id}")
|
| 28 |
-
print(f"Downloading model {model_id} from GitHub URL {url} to {local_dir}")
|
| 29 |
-
# Extract filename from URL
|
| 30 |
-
filename = os.path.join(local_dir, os.path.basename(url))
|
| 31 |
-
response = requests.get(url, stream=True)
|
| 32 |
-
if response.status_code == 200:
|
| 33 |
-
with open(filename, 'wb') as f:
|
| 34 |
-
for chunk in response.iter_content(chunk_size=8192):
|
| 35 |
-
if chunk:
|
| 36 |
-
f.write(chunk)
|
| 37 |
-
print(f"Successfully downloaded {model_id} to {filename}")
|
| 38 |
-
else:
|
| 39 |
-
raise ValueError(f"Failed to download {model_id} from {url}: HTTP {response.status_code}")
|
| 40 |
-
else:
|
| 41 |
-
raise ValueError(f"Unsupported platform: {platform}")
|
| 42 |
-
|
| 43 |
-
if __name__ == "__main__":
|
| 44 |
-
parser = argparse.ArgumentParser(description="Download model checkpoints from HuggingFace or GitHub.")
|
| 45 |
-
parser.add_argument('--config', type=str, default="configs/model_ckpts.yaml",
|
| 46 |
-
help="Path to the YAML configuration file")
|
| 47 |
-
args = parser.parse_args()
|
| 48 |
-
|
| 49 |
-
# Load the YAML configuration
|
| 50 |
-
config = load_config(args.config)
|
| 51 |
-
|
| 52 |
-
# Iterate through models in the config
|
| 53 |
-
for model_config in config:
|
| 54 |
-
model_id = model_config['model_id']
|
| 55 |
-
local_dir = model_config['local_dir']
|
| 56 |
-
platform = model_config['platform']
|
| 57 |
-
url = model_config.get('url') # Get URL if it exists, None otherwise
|
| 58 |
-
download_model(model_id, local_dir, platform, url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|