Upload download_models.py with huggingface_hub
Browse files- download_models.py +38 -10
download_models.py
CHANGED
@@ -3,29 +3,33 @@ import subprocess
|
|
3 |
import requests
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
|
|
|
|
|
|
|
|
|
6 |
# Create directories
|
7 |
-
os.makedirs("/
|
8 |
-
os.makedirs("/
|
9 |
-
os.makedirs("/
|
10 |
-
os.makedirs("/
|
11 |
-
os.makedirs("/
|
12 |
|
13 |
# List of models to download
|
14 |
models = [
|
15 |
# SDXL Checkpoint
|
16 |
-
{"repo_id": "Lykon/DreamShaper-XL-Turbo", "filename": "dreamshaperXL_turboDpmppSDEKarras.safetensors", "local_path": "/
|
17 |
|
18 |
# ControlNet model
|
19 |
-
{"repo_id": "thibaud/controlnet-openpose-sdxl-1.0", "filename": "diffusion_pytorch_model.safetensors", "local_path": "/
|
20 |
|
21 |
# IP-Adapter
|
22 |
-
{"repo_id": "h94/IP-Adapter", "filename": "ip-adapter_sdxl.safetensors", "local_path": "/
|
23 |
|
24 |
# PuLID model
|
25 |
-
{"repo_id": "l7dev/ip-adapter-pulid-sdxl", "filename": "ip-adapter_pulid_sdxl_fp16.safetensors", "local_path": "/
|
26 |
|
27 |
# CLIP Vision
|
28 |
-
{"repo_id": "h94/IP-Adapter", "filename": "CLIP-ViT-bigG-14-laion2B-39B-b160k.safetensors", "local_path": "/
|
29 |
]
|
30 |
|
31 |
# Download each model
|
@@ -54,3 +58,27 @@ for model in models:
|
|
54 |
print(f"Successfully downloaded {model['filename']}")
|
55 |
except Exception as e:
|
56 |
print(f"Error downloading {model['filename']}: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import requests
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
+
# Use writable directories
|
7 |
+
BASE_DIR = "/tmp"
|
8 |
+
MODELS_DIR = f"{BASE_DIR}/comfyui_models"
|
9 |
+
|
10 |
# Create directories
|
11 |
+
os.makedirs(f"{MODELS_DIR}/checkpoints", exist_ok=True)
|
12 |
+
os.makedirs(f"{MODELS_DIR}/controlnet", exist_ok=True)
|
13 |
+
os.makedirs(f"{MODELS_DIR}/ipadapter", exist_ok=True)
|
14 |
+
os.makedirs(f"{MODELS_DIR}/pulid", exist_ok=True)
|
15 |
+
os.makedirs(f"{MODELS_DIR}/clip_vision", exist_ok=True)
|
16 |
|
17 |
# List of models to download
|
18 |
models = [
|
19 |
# SDXL Checkpoint
|
20 |
+
{"repo_id": "Lykon/DreamShaper-XL-Turbo", "filename": "dreamshaperXL_turboDpmppSDEKarras.safetensors", "local_path": f"{MODELS_DIR}/checkpoints/dreamshaperXL_turboDpmppSDEKarras.safetensors"},
|
21 |
|
22 |
# ControlNet model
|
23 |
+
{"repo_id": "thibaud/controlnet-openpose-sdxl-1.0", "filename": "diffusion_pytorch_model.safetensors", "local_path": f"{MODELS_DIR}/controlnet/thibaud_xl_openpose.safetensors"},
|
24 |
|
25 |
# IP-Adapter
|
26 |
+
{"repo_id": "h94/IP-Adapter", "filename": "ip-adapter_sdxl.safetensors", "local_path": f"{MODELS_DIR}/ipadapter/ip-adapter_sdxl.safetensors"},
|
27 |
|
28 |
# PuLID model
|
29 |
+
{"repo_id": "l7dev/ip-adapter-pulid-sdxl", "filename": "ip-adapter_pulid_sdxl_fp16.safetensors", "local_path": f"{MODELS_DIR}/pulid/ip-adapter_pulid_sdxl_fp16.safetensors"},
|
30 |
|
31 |
# CLIP Vision
|
32 |
+
{"repo_id": "h94/IP-Adapter", "filename": "CLIP-ViT-bigG-14-laion2B-39B-b160k.safetensors", "local_path": f"{MODELS_DIR}/clip_vision/CLIP-ViT-bigG-14-laion2B-39B-b160k.safetensors"}
|
33 |
]
|
34 |
|
35 |
# Download each model
|
|
|
58 |
print(f"Successfully downloaded {model['filename']}")
|
59 |
except Exception as e:
|
60 |
print(f"Error downloading {model['filename']}: {str(e)}")
|
61 |
+
|
62 |
+
# Create symbolic links for standard ComfyUI paths
|
63 |
+
print("Creating symbolic links to models directory...")
|
64 |
+
try:
|
65 |
+
# Link from ComfyUI's default directories to our writable directory
|
66 |
+
for model_type in ["checkpoints", "controlnet", "ipadapter", "pulid", "clip_vision"]:
|
67 |
+
# Make the original directory if it doesn't exist
|
68 |
+
os.makedirs(f"/app/ComfyUI/models/{model_type}", exist_ok=True)
|
69 |
+
|
70 |
+
# Create symbolic links for each file
|
71 |
+
for filename in os.listdir(f"{MODELS_DIR}/{model_type}"):
|
72 |
+
source = f"{MODELS_DIR}/{model_type}/{filename}"
|
73 |
+
target = f"/app/ComfyUI/models/{model_type}/{filename}"
|
74 |
+
|
75 |
+
if not os.path.exists(target):
|
76 |
+
try:
|
77 |
+
os.symlink(source, target)
|
78 |
+
print(f"Created symlink: {target} -> {source}")
|
79 |
+
except Exception as e:
|
80 |
+
print(f"Error creating symlink {target}: {e}")
|
81 |
+
except Exception as e:
|
82 |
+
print(f"Error setting up symbolic links: {e}")
|
83 |
+
|
84 |
+
print("Model download completed.")
|