eshwar06 commited on
Commit
46e3a12
·
verified ·
1 Parent(s): 4263188

Update download_models.py

Browse files
Files changed (1) hide show
  1. download_models.py +86 -30
download_models.py CHANGED
@@ -1,30 +1,86 @@
1
- import os
2
- from huggingface_hub import snapshot_download
3
-
4
- # Target directory matches where MuseTalk expects to find models
5
- TARGET_DIR = "./Musetalk/models"
6
-
7
- def download_models():
8
- print(f"🚀 Downloading MuseTalk models to {TARGET_DIR}...")
9
-
10
- # Ensure directory exists
11
- os.makedirs(TARGET_DIR, exist_ok=True)
12
-
13
- # Download specific subfolders from the official repo
14
- # This gets: musetalk, dwpose, sd-vae-ft-mse, and face-parse-bisent
15
- snapshot_download(
16
- repo_id="TMElyralab/MuseTalk",
17
- local_dir=TARGET_DIR,
18
- allow_patterns=[
19
- "musetalk/*",
20
- "sd-vae-ft-mse/*",
21
- "dwpose/*",
22
- "face-parse-bisent/*"
23
- ],
24
- local_dir_use_symlinks=False # Crucial for Docker
25
- )
26
-
27
- print("✅ All MuseTalk models downloaded successfully.")
28
-
29
- if __name__ == "__main__":
30
- download_models()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ # Target directory matches where MuseTalk expects to find models
6
+ TARGET_DIR = "./Musetalk/models"
7
+
8
+ def download_file(url, dest_path):
9
+ """Download a file from URL to destination path."""
10
+ os.makedirs(os.path.dirname(dest_path), exist_ok=True)
11
+ print(f"📥 Downloading {os.path.basename(dest_path)}...")
12
+ response = requests.get(url, stream=True)
13
+ response.raise_for_status()
14
+ with open(dest_path, 'wb') as f:
15
+ for chunk in response.iter_content(chunk_size=8192):
16
+ f.write(chunk)
17
+ print(f"✅ {os.path.basename(dest_path)} downloaded")
18
+
19
+ def download_models():
20
+ print(f"🚀 Downloading MuseTalk models to {TARGET_DIR}...")
21
+ os.makedirs(TARGET_DIR, exist_ok=True)
22
+
23
+ # 1. DWPose models
24
+ print("\n📦 Downloading DWPose models...")
25
+ download_file(
26
+ "https://huggingface.co/yzd-v/DWPose/resolve/main/dw-ll_ucoco_384.pth",
27
+ f"{TARGET_DIR}/dwpose/dw-ll_ucoco_384.pth"
28
+ )
29
+ download_file(
30
+ "https://huggingface.co/yzd-v/DWPose/resolve/main/yolox_l.onnx",
31
+ f"{TARGET_DIR}/dwpose/yolox_l.onnx"
32
+ )
33
+
34
+ # 2. Face Parsing models
35
+ print("\n📦 Downloading Face Parsing models...")
36
+ download_file(
37
+ "https://huggingface.co/leonelhs/faceparser/resolve/main/79999_iter.pth",
38
+ f"{TARGET_DIR}/face-parse-bisent/79999_iter.pth"
39
+ )
40
+ download_file(
41
+ "https://download.pytorch.org/models/resnet18-5c106cde.pth",
42
+ f"{TARGET_DIR}/face-parse-bisent/resnet18-5c106cde.pth"
43
+ )
44
+
45
+ # 3. VAE models
46
+ print("\n📦 Downloading VAE models...")
47
+ download_file(
48
+ "https://huggingface.co/stabilityai/sd-vae-ft-mse/resolve/main/config.json",
49
+ f"{TARGET_DIR}/sd-vae-ft-mse/config.json"
50
+ )
51
+ download_file(
52
+ "https://huggingface.co/stabilityai/sd-vae-ft-mse/resolve/main/diffusion_pytorch_model.bin",
53
+ f"{TARGET_DIR}/sd-vae-ft-mse/diffusion_pytorch_model.bin"
54
+ )
55
+ download_file(
56
+ "https://huggingface.co/stabilityai/sd-vae-ft-mse/resolve/main/diffusion_pytorch_model.safetensors",
57
+ f"{TARGET_DIR}/sd-vae-ft-mse/diffusion_pytorch_model.safetensors"
58
+ )
59
+
60
+ # 4. MuseTalk checkpoints
61
+ print("\n📦 Downloading MuseTalk checkpoints...")
62
+ hf_hub_download(
63
+ repo_id="TMElyralab/MuseTalk",
64
+ filename="musetalk/musetalk.json",
65
+ local_dir=TARGET_DIR,
66
+ local_dir_use_symlinks=False
67
+ )
68
+ hf_hub_download(
69
+ repo_id="TMElyralab/MuseTalk",
70
+ filename="musetalk/pytorch_model.bin",
71
+ local_dir=TARGET_DIR,
72
+ local_dir_use_symlinks=False
73
+ )
74
+
75
+ # 5. Whisper model (CRITICAL - was missing!)
76
+ print("\n📦 Downloading Whisper model...")
77
+ download_file(
78
+ "https://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.pt",
79
+ f"{TARGET_DIR}/whisper/tiny.pt"
80
+ )
81
+
82
+ print("\n✅ All MuseTalk models downloaded successfully!")
83
+ print(f"📂 Models location: {TARGET_DIR}")
84
+
85
+ if __name__ == "__main__":
86
+ download_models()