Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,31 +2,28 @@ import os
|
|
2 |
import sys
|
3 |
import subprocess
|
4 |
import time
|
|
|
5 |
|
6 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
7 |
-
BASE_DIR = os.getcwd() # current working directory
|
8 |
WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
|
9 |
|
10 |
-
# This path assumes the checkpoint is inside weights/transformers/...
|
11 |
CHECKPOINT_FILE = os.path.join(WEIGHTS_DIR, "transformers", "mp_rank_00_model_states.pt")
|
12 |
|
13 |
def download_model():
|
14 |
-
print("⬇️
|
15 |
os.makedirs(WEIGHTS_DIR, exist_ok=True)
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
proc = subprocess.run(cmd)
|
23 |
-
if proc.returncode != 0:
|
24 |
-
print("❌ huggingface-cli download failed.")
|
25 |
-
sys.exit(1)
|
26 |
|
27 |
if not os.path.isfile(CHECKPOINT_FILE):
|
28 |
print(f"❌ Checkpoint file not found at {CHECKPOINT_FILE} after download.")
|
29 |
sys.exit(1)
|
|
|
30 |
print("✅ Model downloaded successfully.")
|
31 |
|
32 |
def run_flask_audio():
|
@@ -63,7 +60,7 @@ def main():
|
|
63 |
download_model()
|
64 |
|
65 |
flask_proc = run_flask_audio()
|
66 |
-
time.sleep(5) # Wait a
|
67 |
gradio_proc = run_gradio_ui()
|
68 |
|
69 |
if __name__ == "__main__":
|
|
|
2 |
import sys
|
3 |
import subprocess
|
4 |
import time
|
5 |
+
from huggingface_hub import snapshot_download
|
6 |
|
7 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
8 |
+
BASE_DIR = os.getcwd() # current working directory absolute path
|
9 |
WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
|
10 |
|
|
|
11 |
CHECKPOINT_FILE = os.path.join(WEIGHTS_DIR, "transformers", "mp_rank_00_model_states.pt")
|
12 |
|
13 |
def download_model():
|
14 |
+
print("⬇️ Model not found. Downloading with snapshot_download into weights directory...")
|
15 |
os.makedirs(WEIGHTS_DIR, exist_ok=True)
|
16 |
|
17 |
+
snapshot_download(
|
18 |
+
repo_id=MODEL_REPO,
|
19 |
+
local_dir=WEIGHTS_DIR,
|
20 |
+
local_dir_use_symlinks=False # Force copy instead of symlink for clarity
|
21 |
+
)
|
|
|
|
|
|
|
|
|
22 |
|
23 |
if not os.path.isfile(CHECKPOINT_FILE):
|
24 |
print(f"❌ Checkpoint file not found at {CHECKPOINT_FILE} after download.")
|
25 |
sys.exit(1)
|
26 |
+
|
27 |
print("✅ Model downloaded successfully.")
|
28 |
|
29 |
def run_flask_audio():
|
|
|
60 |
download_model()
|
61 |
|
62 |
flask_proc = run_flask_audio()
|
63 |
+
time.sleep(5) # Wait a little for flask_audio.py to start
|
64 |
gradio_proc = run_gradio_ui()
|
65 |
|
66 |
if __name__ == "__main__":
|