-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpreload_model.py
More file actions
59 lines (52 loc) · 1.85 KB
/
preload_model.py
File metadata and controls
59 lines (52 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# premodel_download.py
def ensure_models():
from huggingface_hub import snapshot_download
from pathlib import Path
WAN_REPO_ID = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
LORA_REPO_ID = "Kijai/WanVideo_comfy"
BASE_MODEL_DIR = Path("/runpod-volume/models/Wan2.2-I2V-A14B-Diffusers")
LORA_DIR = Path("/runpod-volume/models/lora/WanVideo_comfy")
WAN_SENTINEL = BASE_MODEL_DIR / "model_index.json"
LORA_SENTINEL = (
LORA_DIR
/ "Lightx2v"
/ "lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors"
)
BASE_MODEL_DIR.mkdir(parents=True, exist_ok=True)
LORA_DIR.mkdir(parents=True, exist_ok=True)
# ---- Base Wan 2.2 model ----
if not WAN_SENTINEL.exists():
print("⬇️ Downloading Wan 2.2 base model...")
snapshot_download(
repo_id=WAN_REPO_ID,
repo_type="model",
local_dir=str(BASE_MODEL_DIR),
cache_dir="/runpod-volume/huggingface",
local_dir_use_symlinks=False,
allow_patterns=[
"model_index.json",
"scheduler/*",
"text_encoder/*",
"tokenizer/*",
"transformer/*",
"transformer_2/*",
"vae/*",
],
)
else:
print("✅ Wan 2.2 base model already present")
# ---- LoRA ----
if not LORA_SENTINEL.exists():
print("⬇️ Downloading Wan LoRA...")
snapshot_download(
repo_id=LORA_REPO_ID,
repo_type="model",
local_dir=str(LORA_DIR),
cache_dir="/runpod-volume/huggingface",
local_dir_use_symlinks=False,
allow_patterns=[
"Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors"
],
)
else:
print("✅ Wan LoRA already present")