-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.py
More file actions
60 lines (48 loc) · 1.93 KB
/
start_server.py
File metadata and controls
60 lines (48 loc) · 1.93 KB
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
"""
Start the Hunyuan3D API server.
Usage:
python start_server.py # Default settings
python start_server.py --low-vram # Offload between stages (saves VRAM)
python start_server.py --port 9090 # Custom port
Once running, generate meshes with:
python client.py --image photo.png
"""
import argparse
import os
import subprocess
import sys
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
REPO_DIR = os.path.join(SCRIPT_DIR, "Hunyuan3D-2.1")
# Use venv Python if it exists, otherwise fall back to current interpreter
_venv_python = os.path.join(SCRIPT_DIR, "venv", "Scripts", "python.exe")
VENV_PYTHON = _venv_python if os.path.isfile(_venv_python) else sys.executable
def main():
parser = argparse.ArgumentParser(description="Start Hunyuan3D API server")
parser.add_argument("--port", type=int, default=8081, help="Port (default: 8081)")
parser.add_argument("--host", default="127.0.0.1", help="Host (default: 127.0.0.1)")
parser.add_argument("--low-vram", action="store_true", help="Enable low VRAM mode")
parser.add_argument("--model-path", default="tencent/Hunyuan3D-2.1", help="Model path")
args = parser.parse_args()
cmd = [
VENV_PYTHON,
os.path.join(REPO_DIR, "api_server.py"),
"--host", args.host,
"--port", str(args.port),
"--model_path", args.model_path,
"--subfolder", "hunyuan3d-dit-v2-1",
]
if args.low_vram:
cmd.append("--low_vram_mode")
print(f"Starting Hunyuan3D server on {args.host}:{args.port}")
print(f"Model: {args.model_path}")
print(f"Low VRAM: {args.low_vram}")
print()
print("The first start downloads model weights (~6GB). Subsequent starts use cached weights.")
print("Press Ctrl+C to stop.\n")
os.chdir(REPO_DIR)
try:
subprocess.run(cmd, check=True)
except KeyboardInterrupt:
print("\nServer stopped.")
if __name__ == "__main__":
main()