BladeSzaSza commited on
Commit
fe9f0b9
Β·
1 Parent(s): 55083e9

fix(3d): Add detailed logging to setup process

Browse files

- Wraps the setup commands (pip install, compile) in a helper function that captures and logs stdout/stderr for both success and failure cases.
- Adds the mirror URLs provided by the user to the pip install command to aid package discovery.
- This change is intended to expose the underlying error that is causing the installation to fail silently.

Files changed (1) hide show
  1. models/model_3d_generator.py +32 -7
models/model_3d_generator.py CHANGED
@@ -86,29 +86,54 @@ class Hunyuan3DGenerator:
86
  logger.info(f"βœ… Model repository downloaded to: {self.model_path}")
87
 
88
  # --- Installation and Compilation ---
89
- logger.info("πŸ”§ Running Hunyuan3D setup scripts...")
90
  import subprocess
91
  import sys
92
  import os
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  # 1. Install requirements from the model's specific requirements file
95
  requirements_path = os.path.join(self.model_path, 'requirements.txt')
96
  if os.path.exists(requirements_path):
97
- logger.info(f"πŸ“¦ Installing requirements from {requirements_path}...")
98
- subprocess.run([sys.executable, '-m', 'pip', 'install', '-r', requirements_path], check=True, capture_output=True, text=True)
 
 
 
 
99
 
100
  # 2. Install custom rasterizer
101
  rasterizer_path = os.path.join(self.model_path, 'hy3dpaint', 'packages', 'custom_rasterizer')
102
  if os.path.exists(rasterizer_path):
103
- logger.info(f"πŸ“¦ Installing custom_rasterizer from {rasterizer_path}...")
104
- subprocess.run([sys.executable, '-m', 'pip', 'install', '-e', '.'], cwd=rasterizer_path, check=True, capture_output=True, text=True)
105
 
106
  # 3. Compile mesh painter
107
  renderer_path = os.path.join(self.model_path, 'hy3dpaint', 'DifferentiableRenderer')
108
  compile_script_path = os.path.join(renderer_path, 'compile_mesh_painter.sh')
109
  if os.path.exists(compile_script_path):
110
- logger.info(f"πŸ–ŒοΈ Compiling mesh painter in {renderer_path}...")
111
- subprocess.run(['bash', 'compile_mesh_painter.sh'], cwd=renderer_path, check=True, capture_output=True, text=True)
112
 
113
  logger.info("βœ… Hunyuan3D setup completed successfully.")
114
 
 
86
  logger.info(f"βœ… Model repository downloaded to: {self.model_path}")
87
 
88
  # --- Installation and Compilation ---
89
+ logger.info("πŸ”§ Running Hunyuan3D setup scripts with detailed logging...")
90
  import subprocess
91
  import sys
92
  import os
93
 
94
+ def run_setup_command(command, cwd):
95
+ logger.info(f"Running command: {' '.join(command)} in {cwd}")
96
+ try:
97
+ process = subprocess.run(
98
+ command,
99
+ check=True,
100
+ capture_output=True,
101
+ text=True,
102
+ cwd=cwd
103
+ )
104
+ logger.info(f"βœ… Command successful.")
105
+ if process.stdout:
106
+ logger.info(f"STDOUT:\n{process.stdout}")
107
+ if process.stderr:
108
+ logger.warning(f"STDERR:\n{process.stderr}")
109
+ except subprocess.CalledProcessError as e:
110
+ logger.error(f"❌ Command failed with exit code {e.returncode}")
111
+ logger.error(f"STDOUT:\n{e.stdout}")
112
+ logger.error(f"STDERR:\n{e.stderr}")
113
+ raise # Re-raise the exception to halt execution and see the error
114
+
115
  # 1. Install requirements from the model's specific requirements file
116
  requirements_path = os.path.join(self.model_path, 'requirements.txt')
117
  if os.path.exists(requirements_path):
118
+ pip_command = [
119
+ sys.executable, '-m', 'pip', 'install', '-r', requirements_path,
120
+ '--extra-index-url', 'https://mirrors.cloud.tencent.com/pypi/simple/',
121
+ '--extra-index-url', 'https://mirrors.aliyun.com/pypi/simple'
122
+ ]
123
+ run_setup_command(pip_command, cwd=self.model_path)
124
 
125
  # 2. Install custom rasterizer
126
  rasterizer_path = os.path.join(self.model_path, 'hy3dpaint', 'packages', 'custom_rasterizer')
127
  if os.path.exists(rasterizer_path):
128
+ pip_command_rasterizer = [sys.executable, '-m', 'pip', 'install', '-e', '.']
129
+ run_setup_command(pip_command_rasterizer, cwd=rasterizer_path)
130
 
131
  # 3. Compile mesh painter
132
  renderer_path = os.path.join(self.model_path, 'hy3dpaint', 'DifferentiableRenderer')
133
  compile_script_path = os.path.join(renderer_path, 'compile_mesh_painter.sh')
134
  if os.path.exists(compile_script_path):
135
+ bash_command = ['bash', compile_script_path]
136
+ run_setup_command(bash_command, cwd=renderer_path)
137
 
138
  logger.info("βœ… Hunyuan3D setup completed successfully.")
139