Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,4 +49,93 @@ def download_model():
|
|
| 49 |
print(f"β FP8 Checkpoint missing at {CHECKPOINT_FP8_FILE}")
|
| 50 |
sys.exit(1)
|
| 51 |
|
| 52 |
-
print("β
Model downloaded
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
print(f"β FP8 Checkpoint missing at {CHECKPOINT_FP8_FILE}")
|
| 50 |
sys.exit(1)
|
| 51 |
|
| 52 |
+
print("β
Model downloaded successfully.")
|
| 53 |
+
clear_hf_cache()
|
| 54 |
+
|
| 55 |
+
def run_sample_gpu_poor():
|
| 56 |
+
print("π¬ Running sample_gpu_poor.py...")
|
| 57 |
+
|
| 58 |
+
cmd = [
|
| 59 |
+
"python3", "hymm_sp/sample_gpu_poor.py",
|
| 60 |
+
"--input", "assets/test.csv",
|
| 61 |
+
"--ckpt", CHECKPOINT_FP8_FILE,
|
| 62 |
+
"--sample-n-frames", "129",
|
| 63 |
+
"--seed", "128",
|
| 64 |
+
"--image-size", "704",
|
| 65 |
+
"--cfg-scale", "7.5",
|
| 66 |
+
"--infer-steps", "50",
|
| 67 |
+
"--use-deepcache", "1",
|
| 68 |
+
"--flow-shift-eval-video", "5.0",
|
| 69 |
+
"--save-path", OUTPUT_BASEPATH,
|
| 70 |
+
"--use-fp8",
|
| 71 |
+
"--cpu-offload",
|
| 72 |
+
"--infer-min"
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
env = os.environ.copy()
|
| 76 |
+
env.update(HF_HOME_ENV)
|
| 77 |
+
env["PYTHONPATH"] = "./"
|
| 78 |
+
env["MODEL_BASE"] = WEIGHTS_DIR
|
| 79 |
+
env["CPU_OFFLOAD"] = "1"
|
| 80 |
+
env["CUDA_VISIBLE_DEVICES"] = "0"
|
| 81 |
+
|
| 82 |
+
result = subprocess.run(cmd, env=env)
|
| 83 |
+
if result.returncode != 0:
|
| 84 |
+
print("β sample_gpu_poor.py failed.")
|
| 85 |
+
sys.exit(1)
|
| 86 |
+
|
| 87 |
+
print("β
sample_gpu_poor.py completed.")
|
| 88 |
+
|
| 89 |
+
def run_flask_audio():
|
| 90 |
+
print("π Starting flask_audio.py...")
|
| 91 |
+
cmd = [
|
| 92 |
+
"torchrun",
|
| 93 |
+
"--nnodes=1",
|
| 94 |
+
"--nproc_per_node=8",
|
| 95 |
+
"--master_port=29605",
|
| 96 |
+
"hymm_gradio/flask_audio.py",
|
| 97 |
+
"--input", "assets/test.csv",
|
| 98 |
+
"--ckpt", CHECKPOINT_FILE,
|
| 99 |
+
"--sample-n-frames", "129",
|
| 100 |
+
"--seed", "128",
|
| 101 |
+
"--image-size", "704",
|
| 102 |
+
"--cfg-scale", "7.5",
|
| 103 |
+
"--infer-steps", "50",
|
| 104 |
+
"--use-deepcache", "1",
|
| 105 |
+
"--flow-shift-eval-video", "5.0"
|
| 106 |
+
]
|
| 107 |
+
subprocess.Popen(cmd)
|
| 108 |
+
|
| 109 |
+
def run_gradio_ui():
|
| 110 |
+
print("π’ Launching Gradio UI...")
|
| 111 |
+
cmd = ["python3", "hymm_gradio/gradio_audio.py"]
|
| 112 |
+
subprocess.Popen(cmd)
|
| 113 |
+
|
| 114 |
+
def create_gitignore():
|
| 115 |
+
gitignore_path = os.path.join(BASE_DIR, ".gitignore")
|
| 116 |
+
lines_to_add = ["weights/", "results-*/", ".cache/"]
|
| 117 |
+
with open(gitignore_path, "a+") as f:
|
| 118 |
+
f.seek(0)
|
| 119 |
+
existing = f.read().splitlines()
|
| 120 |
+
for line in lines_to_add:
|
| 121 |
+
if line not in existing:
|
| 122 |
+
f.write(f"{line}\n")
|
| 123 |
+
|
| 124 |
+
def main():
|
| 125 |
+
create_gitignore()
|
| 126 |
+
check_disk_space(min_free_gb=10)
|
| 127 |
+
|
| 128 |
+
if os.path.isfile(CHECKPOINT_FILE) and os.path.isfile(CHECKPOINT_FP8_FILE):
|
| 129 |
+
print("β
Checkpoints exist. Skipping download.")
|
| 130 |
+
else:
|
| 131 |
+
download_model()
|
| 132 |
+
|
| 133 |
+
run_sample_gpu_poor()
|
| 134 |
+
|
| 135 |
+
# Optional: Launch UIs
|
| 136 |
+
run_flask_audio()
|
| 137 |
+
time.sleep(5)
|
| 138 |
+
run_gradio_ui()
|
| 139 |
+
|
| 140 |
+
if __name__ == "__main__":
|
| 141 |
+
main()
|