Spaces:
Runtime error
Runtime error
File size: 2,105 Bytes
c1f7300 d491e94 093967b c1f7300 093967b 956b411 093967b 956b411 edc3608 c1f7300 d491e94 edc3608 093967b edc3608 093967b edc3608 d491e94 093967b d491e94 c1f7300 d491e94 edc3608 d491e94 |
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 60 61 62 63 64 65 66 67 68 69 70 71 |
import os
import sys
import subprocess
import time
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
BASE_DIR = os.getcwd() # current working directory, absolute path
WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
# This path assumes the checkpoint is inside weights/transformers/...
CHECKPOINT_FILE = os.path.join(WEIGHTS_DIR, "transformers", "mp_rank_00_model_states.pt")
def download_model():
print("β¬οΈ Model not found. Downloading with huggingface-cli inside weights directory...")
os.makedirs(WEIGHTS_DIR, exist_ok=True)
# Use --local-dir as absolute path (important!)
cmd = [
"huggingface-cli", "download", MODEL_REPO,
"--local-dir", WEIGHTS_DIR
]
proc = subprocess.run(cmd)
if proc.returncode != 0:
print("β huggingface-cli download failed.")
sys.exit(1)
if not os.path.isfile(CHECKPOINT_FILE):
print(f"β Checkpoint file not found at {CHECKPOINT_FILE} after download.")
sys.exit(1)
print("β
Model downloaded successfully.")
def run_flask_audio():
print("π Starting flask_audio.py...")
cmd = [
"torchrun",
"--nnodes=1",
"--nproc_per_node=8",
"--master_port=29605",
"hymm_gradio/flask_audio.py",
"--input", "assets/test.csv",
"--ckpt", CHECKPOINT_FILE,
"--sample-n-frames", "129",
"--seed", "128",
"--image-size", "704",
"--cfg-scale", "7.5",
"--infer-steps", "50",
"--use-deepcache", "1",
"--flow-shift-eval-video", "5.0"
]
proc = subprocess.Popen(cmd)
return proc
def run_gradio_ui():
print("π’ Starting gradio_audio.py UI...")
cmd = ["python3", "hymm_gradio/gradio_audio.py"]
proc = subprocess.Popen(cmd)
return proc
def main():
if os.path.isfile(CHECKPOINT_FILE):
print("β
Model checkpoint already exists. Skipping download.")
else:
download_model()
flask_proc = run_flask_audio()
time.sleep(5) # Wait a bit for flask_audio.py to start
gradio_proc = run_gradio_ui()
if __name__ == "__main__":
main()
|