Spaces:
Running
Running
Update GhostPackDemo/install.py
Browse files- GhostPackDemo/install.py +31 -32
GhostPackDemo/install.py
CHANGED
@@ -5,57 +5,56 @@ import sys
|
|
5 |
import subprocess
|
6 |
import shutil
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
def run(cmd
|
16 |
print(f"> {' '.join(cmd)}")
|
17 |
-
subprocess.check_call(cmd
|
18 |
|
19 |
def main():
|
20 |
-
#
|
21 |
-
if
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
if
|
27 |
-
|
28 |
-
else:
|
29 |
-
run(["nvidia-smi"])
|
30 |
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
#
|
35 |
if not os.path.isdir(ENV_DIR):
|
36 |
-
print("Creating virtual environment...")
|
37 |
run([sys.executable, "-m", "venv", ENV_DIR])
|
38 |
|
39 |
if os.name == "nt":
|
40 |
pip = os.path.join(ENV_DIR, "Scripts", "pip.exe")
|
41 |
-
|
42 |
else:
|
43 |
pip = os.path.join(ENV_DIR, "bin", "pip")
|
44 |
-
|
45 |
|
46 |
-
#
|
47 |
run([pip, "install", "--upgrade", "pip"])
|
48 |
run([pip, "install", "-r", "requirements.txt"])
|
49 |
|
50 |
-
#
|
51 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
52 |
-
run([
|
53 |
-
run([
|
54 |
-
f"from huggingface_hub import snapshot_download; snapshot_download('{
|
55 |
|
56 |
-
print("\nSetup complete
|
57 |
-
print("
|
58 |
-
print(f" source {ENV_DIR}/bin/activate && python ghostpack_main_fixed.py --server 0.0.0.0 --port 7860")
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
main()
|
|
|
5 |
import subprocess
|
6 |
import shutil
|
7 |
|
8 |
+
# Repo and subdir
|
9 |
+
REPO_URL = "https://huggingface.co/spaces/ghostai1/GhostPack.git"
|
10 |
+
SUBDIR = "GhostPackDemo"
|
11 |
+
ENV_DIR = "venv"
|
12 |
+
CACHE_DIR = "hf_download"
|
13 |
+
MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
|
14 |
+
|
15 |
+
def run(cmd):
|
16 |
print(f"> {' '.join(cmd)}")
|
17 |
+
subprocess.check_call(cmd)
|
18 |
|
19 |
def main():
|
20 |
+
# Clone or update repo
|
21 |
+
if not os.path.isdir("GhostPack"):
|
22 |
+
run(["git", "clone", REPO_URL])
|
23 |
+
os.chdir(os.path.join("GhostPack", SUBDIR))
|
24 |
|
25 |
+
# Python version check
|
26 |
+
if sys.version_info < (3,8):
|
27 |
+
sys.exit("Python 3.8+ required")
|
|
|
|
|
28 |
|
29 |
+
# CUDA/GPU check
|
30 |
+
if shutil.which("nvidia-smi") is None:
|
31 |
+
print("Warning: nvidia-smi not found; CUDA will be unavailable")
|
32 |
+
if shutil.which("nvcc") is None:
|
33 |
+
print("Warning: nvcc not found; install CUDA toolkit for best performance")
|
34 |
|
35 |
+
# Virtual env
|
36 |
if not os.path.isdir(ENV_DIR):
|
|
|
37 |
run([sys.executable, "-m", "venv", ENV_DIR])
|
38 |
|
39 |
if os.name == "nt":
|
40 |
pip = os.path.join(ENV_DIR, "Scripts", "pip.exe")
|
41 |
+
py = os.path.join(ENV_DIR, "Scripts", "python.exe")
|
42 |
else:
|
43 |
pip = os.path.join(ENV_DIR, "bin", "pip")
|
44 |
+
py = os.path.join(ENV_DIR, "bin", "python")
|
45 |
|
46 |
+
# Install dependencies
|
47 |
run([pip, "install", "--upgrade", "pip"])
|
48 |
run([pip, "install", "-r", "requirements.txt"])
|
49 |
|
50 |
+
# HF login + cache model
|
51 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
52 |
+
run([py, "-c", "from diffusers_helper.hf_login import login; login()"])
|
53 |
+
run([py, "-c",
|
54 |
+
f"from huggingface_hub import snapshot_download; snapshot_download('{MODEL_ID}', cache_dir='{CACHE_DIR}')"])
|
55 |
|
56 |
+
print("\nSetup complete.")
|
57 |
+
print(f"cd GhostPack/{SUBDIR} && source {ENV_DIR}/bin/activate && python ghostpack_main_fixed.py --server 0.0.0.0 --port 7860")
|
|
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
main()
|