ghostai1 commited on
Commit
1bda3d6
·
verified ·
1 Parent(s): 48fbf7f

Update GhostPackDemo/install.py

Browse files
Files changed (1) hide show
  1. GhostPackDemo/install.py +17 -15
GhostPackDemo/install.py CHANGED
@@ -1,4 +1,6 @@
1
- # install.py
 
 
2
  #!/usr/bin/env python3
3
  import os, sys, subprocess, shutil, platform, venv
4
 
@@ -6,19 +8,19 @@ ENV_DIR = "venv"
6
  CACHE_DIR = "hf_download"
7
  MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
8
 
9
- def run(cmd: list[str]):
10
  print("❯", *cmd, flush=True)
11
  subprocess.check_call(cmd)
12
 
13
- def ensure_python():
14
  if sys.version_info < (3, 8):
15
- sys.exit("Python 3.8 or newer required.")
16
 
17
- def cuda_info():
18
  if shutil.which("nvidia-smi"):
19
  run(["nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv"])
20
  else:
21
- print("⚠️ CUDA GPU not foundfall-back to CPU (slow).")
22
 
23
  def create_venv() -> tuple[str, str]:
24
  if not os.path.isdir(ENV_DIR):
@@ -32,14 +34,14 @@ def create_venv() -> tuple[str, str]:
32
  py = os.path.join(ENV_DIR, "bin", "python")
33
  return pip, py
34
 
35
- def install_deps(pip: str):
36
  run([pip, "install", "--upgrade", "pip"])
37
  run([pip, "install", "-r", "requirements.txt"])
38
 
39
- def hf_login(py: str):
40
  run([py, "-c", "from diffusers_helper.hf_login import login; login()"])
41
 
42
- def download_model(py: str):
43
  os.makedirs(CACHE_DIR, exist_ok=True)
44
  code = (
45
  f"from huggingface_hub import snapshot_download;"
@@ -47,18 +49,18 @@ def download_model(py: str):
47
  )
48
  run([py, "-c", code])
49
 
50
- def main():
51
  ensure_python()
52
  cuda_info()
53
  pip, py = create_venv()
54
- install_deps(pip)
55
  hf_login(py)
56
- download_model(py)
57
- print("\n✅ Setup complete. Activate with:")
58
  if platform.system() == "Windows":
59
- print(f" {ENV_DIR}\\Scripts\\Activate.ps1 && python ghostpack_main_fixed.py --inbrowser")
60
  else:
61
- print(f" source {ENV_DIR}/bin/activate && python ghostpack_main_fixed.py --inbrowser")
 
62
 
63
  if __name__ == "__main__":
64
  main()
 
1
+ # ==========================================================
2
+ # FILE: install.py
3
+ # ==========================================================
4
  #!/usr/bin/env python3
5
  import os, sys, subprocess, shutil, platform, venv
6
 
 
8
  CACHE_DIR = "hf_download"
9
  MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
10
 
11
+ def run(cmd: list[str]) -> None:
12
  print("❯", *cmd, flush=True)
13
  subprocess.check_call(cmd)
14
 
15
+ def ensure_python() -> None:
16
  if sys.version_info < (3, 8):
17
+ sys.exit("Python 3.8 or newer required.")
18
 
19
+ def cuda_info() -> None:
20
  if shutil.which("nvidia-smi"):
21
  run(["nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv"])
22
  else:
23
+ print("⚠️ CUDA GPU not detectedfalling back to CPU (slow).")
24
 
25
  def create_venv() -> tuple[str, str]:
26
  if not os.path.isdir(ENV_DIR):
 
34
  py = os.path.join(ENV_DIR, "bin", "python")
35
  return pip, py
36
 
37
+ def install_reqs(pip: str) -> None:
38
  run([pip, "install", "--upgrade", "pip"])
39
  run([pip, "install", "-r", "requirements.txt"])
40
 
41
+ def hf_login(py: str) -> None:
42
  run([py, "-c", "from diffusers_helper.hf_login import login; login()"])
43
 
44
+ def cache_model(py: str) -> None:
45
  os.makedirs(CACHE_DIR, exist_ok=True)
46
  code = (
47
  f"from huggingface_hub import snapshot_download;"
 
49
  )
50
  run([py, "-c", code])
51
 
52
+ def main() -> None:
53
  ensure_python()
54
  cuda_info()
55
  pip, py = create_venv()
56
+ install_reqs(pip)
57
  hf_login(py)
58
+ cache_model(py)
 
59
  if platform.system() == "Windows":
60
+ print(f"\nActivate: {ENV_DIR}\\Scripts\\Activate.ps1")
61
  else:
62
+ print(f"\nActivate: source {ENV_DIR}/bin/activate")
63
+ print("Run: python ghostpack.py --inbrowser")
64
 
65
  if __name__ == "__main__":
66
  main()