ghostai1's picture
Update GhostPackDemo/install.py
dd1c3bf verified
raw
history blame
1.89 kB
# install.py
#!/usr/bin/env python3
import os
import sys
import subprocess
import shutil
# Repo and subdir
REPO_URL = "https://huggingface.co/spaces/ghostai1/GhostPack.git"
SUBDIR = "GhostPackDemo"
ENV_DIR = "venv"
CACHE_DIR = "hf_download"
MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
def run(cmd):
print(f"> {' '.join(cmd)}")
subprocess.check_call(cmd)
def main():
# Clone or update repo
if not os.path.isdir("GhostPack"):
run(["git", "clone", REPO_URL])
os.chdir(os.path.join("GhostPack", SUBDIR))
# Python version check
if sys.version_info < (3,8):
sys.exit("Python 3.8+ required")
# CUDA/GPU check
if shutil.which("nvidia-smi") is None:
print("Warning: nvidia-smi not found; CUDA will be unavailable")
if shutil.which("nvcc") is None:
print("Warning: nvcc not found; install CUDA toolkit for best performance")
# Virtual env
if not os.path.isdir(ENV_DIR):
run([sys.executable, "-m", "venv", ENV_DIR])
if os.name == "nt":
pip = os.path.join(ENV_DIR, "Scripts", "pip.exe")
py = os.path.join(ENV_DIR, "Scripts", "python.exe")
else:
pip = os.path.join(ENV_DIR, "bin", "pip")
py = os.path.join(ENV_DIR, "bin", "python")
# Install dependencies
run([pip, "install", "--upgrade", "pip"])
run([pip, "install", "-r", "requirements.txt"])
# HF login + cache model
os.makedirs(CACHE_DIR, exist_ok=True)
run([py, "-c", "from diffusers_helper.hf_login import login; login()"])
run([py, "-c",
f"from huggingface_hub import snapshot_download; snapshot_download('{MODEL_ID}', cache_dir='{CACHE_DIR}')"])
print("\nSetup complete.")
print(f"cd GhostPack/{SUBDIR} && source {ENV_DIR}/bin/activate && python ghostpack_main_fixed.py --server 0.0.0.0 --port 7860")
if __name__ == "__main__":
main()