Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,58 +1,34 @@
|
|
1 |
import os
|
2 |
-
import sys
|
3 |
import subprocess
|
4 |
import time
|
5 |
-
from
|
6 |
-
from huggingface_hub import snapshot_download
|
7 |
|
8 |
-
# --------------------
|
9 |
-
# CONFIGURATION
|
10 |
-
# --------------------
|
11 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
12 |
-
|
13 |
-
HF_CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
14 |
-
|
15 |
-
CHECKPOINT_FILE = HF_CACHE_DIR / "ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt"
|
16 |
-
CHECKPOINT_FP8_FILE = HF_CACHE_DIR / "ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8.pt"
|
17 |
-
|
18 |
ASSETS_CSV = "assets/test.csv"
|
19 |
-
OUTPUT_DIR = Path("results-poor")
|
20 |
-
OUTPUT_DIR.mkdir(exist_ok=True)
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
# --------------------
|
25 |
-
def download_model():
|
26 |
-
if CHECKPOINT_FILE.exists() and CHECKPOINT_FP8_FILE.exists():
|
27 |
-
print("β
Model checkpoint already exists. Skipping download.")
|
28 |
-
return
|
29 |
|
30 |
-
|
31 |
-
snapshot_download(
|
32 |
repo_id=MODEL_REPO,
|
33 |
-
|
34 |
-
local_dir_use_symlinks=False
|
35 |
)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
if not CHECKPOINT_FP8_FILE.exists():
|
42 |
-
print(f"β Missing FP8 checkpoint: {CHECKPOINT_FP8_FILE}")
|
43 |
-
sys.exit(1)
|
44 |
|
45 |
-
print("β
|
|
|
46 |
|
47 |
-
|
48 |
-
# Run sample_gpu_poor.py
|
49 |
-
# --------------------
|
50 |
-
def run_sample_gpu_poor():
|
51 |
print("π¬ Running sample_gpu_poor.py...")
|
52 |
cmd = [
|
53 |
"python3", "hymm_sp/sample_gpu_poor.py",
|
54 |
"--input", ASSETS_CSV,
|
55 |
-
"--ckpt",
|
56 |
"--sample-n-frames", "129",
|
57 |
"--seed", "128",
|
58 |
"--image-size", "704",
|
@@ -60,7 +36,7 @@ def run_sample_gpu_poor():
|
|
60 |
"--infer-steps", "50",
|
61 |
"--use-deepcache", "1",
|
62 |
"--flow-shift-eval-video", "5.0",
|
63 |
-
"--save-path",
|
64 |
"--use-fp8",
|
65 |
"--cpu-offload",
|
66 |
"--infer-min"
|
@@ -68,30 +44,21 @@ def run_sample_gpu_poor():
|
|
68 |
|
69 |
env = os.environ.copy()
|
70 |
env["PYTHONPATH"] = "./"
|
71 |
-
env["MODEL_BASE"] = str(HF_CACHE_DIR)
|
72 |
-
env["CPU_OFFLOAD"] = "1"
|
73 |
env["CUDA_VISIBLE_DEVICES"] = "0"
|
74 |
|
75 |
proc = subprocess.run(cmd, env=env)
|
76 |
if proc.returncode != 0:
|
77 |
print("β sample_gpu_poor.py failed.")
|
78 |
-
|
79 |
print("β
sample_gpu_poor.py completed successfully.")
|
80 |
|
81 |
-
# --------------------
|
82 |
-
# Optional: Start UI
|
83 |
-
# --------------------
|
84 |
def run_gradio_ui():
|
85 |
print("π’ Launching Gradio interface...")
|
86 |
-
|
87 |
-
subprocess.Popen(cmd)
|
88 |
|
89 |
-
# --------------------
|
90 |
-
# Entry point
|
91 |
-
# --------------------
|
92 |
def main():
|
93 |
-
|
94 |
-
run_sample_gpu_poor()
|
95 |
time.sleep(5)
|
96 |
run_gradio_ui()
|
97 |
|
|
|
1 |
import os
|
|
|
2 |
import subprocess
|
3 |
import time
|
4 |
+
from huggingface_hub import hf_hub_download
|
|
|
5 |
|
|
|
|
|
|
|
6 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
7 |
+
OUTPUT_DIR = "results-poor"
|
|
|
|
|
|
|
|
|
|
|
8 |
ASSETS_CSV = "assets/test.csv"
|
|
|
|
|
9 |
|
10 |
+
def download_checkpoints():
|
11 |
+
print("β¬οΈ Downloading specific checkpoint files from Tencent repo...")
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
fp8_ckpt = hf_hub_download(
|
|
|
14 |
repo_id=MODEL_REPO,
|
15 |
+
filename="ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8.pt"
|
|
|
16 |
)
|
17 |
|
18 |
+
fp32_ckpt = hf_hub_download(
|
19 |
+
repo_id=MODEL_REPO,
|
20 |
+
filename="ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt"
|
21 |
+
)
|
|
|
|
|
|
|
22 |
|
23 |
+
print("β
Checkpoints downloaded.")
|
24 |
+
return fp8_ckpt, fp32_ckpt
|
25 |
|
26 |
+
def run_sample_gpu_poor(fp8_ckpt_path):
|
|
|
|
|
|
|
27 |
print("π¬ Running sample_gpu_poor.py...")
|
28 |
cmd = [
|
29 |
"python3", "hymm_sp/sample_gpu_poor.py",
|
30 |
"--input", ASSETS_CSV,
|
31 |
+
"--ckpt", fp8_ckpt_path,
|
32 |
"--sample-n-frames", "129",
|
33 |
"--seed", "128",
|
34 |
"--image-size", "704",
|
|
|
36 |
"--infer-steps", "50",
|
37 |
"--use-deepcache", "1",
|
38 |
"--flow-shift-eval-video", "5.0",
|
39 |
+
"--save-path", OUTPUT_DIR,
|
40 |
"--use-fp8",
|
41 |
"--cpu-offload",
|
42 |
"--infer-min"
|
|
|
44 |
|
45 |
env = os.environ.copy()
|
46 |
env["PYTHONPATH"] = "./"
|
|
|
|
|
47 |
env["CUDA_VISIBLE_DEVICES"] = "0"
|
48 |
|
49 |
proc = subprocess.run(cmd, env=env)
|
50 |
if proc.returncode != 0:
|
51 |
print("β sample_gpu_poor.py failed.")
|
52 |
+
exit(1)
|
53 |
print("β
sample_gpu_poor.py completed successfully.")
|
54 |
|
|
|
|
|
|
|
55 |
def run_gradio_ui():
|
56 |
print("π’ Launching Gradio interface...")
|
57 |
+
subprocess.Popen(["python3", "hymm_gradio/gradio_audio.py"])
|
|
|
58 |
|
|
|
|
|
|
|
59 |
def main():
|
60 |
+
fp8_ckpt, _ = download_checkpoints()
|
61 |
+
run_sample_gpu_poor(fp8_ckpt)
|
62 |
time.sleep(5)
|
63 |
run_gradio_ui()
|
64 |
|