rahul7star commited on
Commit
edc3608
Β·
verified Β·
1 Parent(s): 956b411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -7,20 +7,23 @@ MODEL_REPO = "tencent/HunyuanVideo-Avatar"
7
  BASE_DIR = os.getcwd() # current working directory, absolute path
8
  WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
9
 
10
- CHECKPOINT_FILE = os.path.join(WEIGHTS_DIR, "transformers/mp_rank_00_model_states.pt") # Adjust if needed
 
11
 
12
  def download_model():
13
- print("⬇️ Model not found. Downloading with huggingface-cli inside HunyuanVideo-Avatar/weights...")
14
  os.makedirs(WEIGHTS_DIR, exist_ok=True)
15
-
16
- # Run huggingface-cli download inside WEIGHTS_DIR
17
- cmd = ["huggingface-cli", "download", MODEL_REPO, "--local-dir", "./"]
18
- proc = subprocess.run(cmd, cwd=WEIGHTS_DIR)
 
 
 
19
  if proc.returncode != 0:
20
  print("❌ huggingface-cli download failed.")
21
  sys.exit(1)
22
-
23
- # Check if checkpoint file exists now
24
  if not os.path.isfile(CHECKPOINT_FILE):
25
  print(f"❌ Checkpoint file not found at {CHECKPOINT_FILE} after download.")
26
  sys.exit(1)
@@ -60,7 +63,7 @@ def main():
60
  download_model()
61
 
62
  flask_proc = run_flask_audio()
63
- time.sleep(5) # Wait for flask_audio.py to spin up
64
  gradio_proc = run_gradio_ui()
65
 
66
  if __name__ == "__main__":
 
7
  BASE_DIR = os.getcwd() # current working directory, absolute path
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("⬇️ Model not found. Downloading with huggingface-cli inside weights directory...")
15
  os.makedirs(WEIGHTS_DIR, exist_ok=True)
16
+
17
+ # Use --local-dir as absolute path (important!)
18
+ cmd = [
19
+ "huggingface-cli", "download", MODEL_REPO,
20
+ "--local-dir", WEIGHTS_DIR
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)
 
63
  download_model()
64
 
65
  flask_proc = run_flask_audio()
66
+ time.sleep(5) # Wait a bit for flask_audio.py to start
67
  gradio_proc = run_gradio_ui()
68
 
69
  if __name__ == "__main__":