Daankular commited on
Commit
85d2e0f
·
1 Parent(s): 9861a7f

Fix triposg: clone source at runtime (no setup.py); remove bad pip install attempt

Browse files
Files changed (2) hide show
  1. app.py +14 -17
  2. requirements.txt +1 -1
app.py CHANGED
@@ -160,18 +160,21 @@ def load_triposg():
160
 
161
  print("[load_triposg] Loading TripoSG pipeline...")
162
  from huggingface_hub import snapshot_download
163
- weights_path = snapshot_download("VAST-AI/TripoSG")
164
 
165
- # TripoSG ships its own pipeline — add to path
166
- triposg_pkg = Path(weights_path)
167
- if (triposg_pkg / "triposg").exists():
168
- sys.path.insert(0, str(triposg_pkg))
169
- else:
170
- # Try installed package from the cloned repo (if installed with pip -e)
171
- import importlib.util
172
- if importlib.util.find_spec("triposg") is None:
173
- import subprocess
174
- subprocess.run([sys.executable, "-m", "pip", "install", "-e", str(triposg_pkg), "-q"], check=False)
 
 
 
 
175
 
176
  from triposg.pipelines.pipeline_triposg import TripoSGPipeline
177
  _triposg_pipe = TripoSGPipeline.from_pretrained(
@@ -250,12 +253,6 @@ def generate_shape(input_image, remove_background, num_steps, guidance_scale,
250
  return None, "Please upload an image."
251
  try:
252
  progress(0.1, desc="Loading TripoSG...")
253
-
254
- # Add TripoSG scripts to path after model download
255
- from huggingface_hub import snapshot_download
256
- weights_path = snapshot_download("VAST-AI/TripoSG")
257
- sys.path.insert(0, weights_path)
258
-
259
  pipe, rmbg_net = load_triposg()
260
 
261
  img = Image.fromarray(input_image).convert("RGB")
 
160
 
161
  print("[load_triposg] Loading TripoSG pipeline...")
162
  from huggingface_hub import snapshot_download
 
163
 
164
+ # TripoSG source has no setup.pyclone GitHub repo and add to sys.path
165
+ triposg_src = Path("/tmp/triposg-src")
166
+ if not triposg_src.exists():
167
+ print("[load_triposg] Cloning TripoSG source...")
168
+ subprocess.run(
169
+ ["git", "clone", "--depth=1",
170
+ "https://github.com/VAST-AI-Research/TripoSG.git",
171
+ str(triposg_src)],
172
+ check=True
173
+ )
174
+ if str(triposg_src) not in sys.path:
175
+ sys.path.insert(0, str(triposg_src))
176
+
177
+ weights_path = snapshot_download("VAST-AI/TripoSG")
178
 
179
  from triposg.pipelines.pipeline_triposg import TripoSGPipeline
180
  _triposg_pipe = TripoSGPipeline.from_pretrained(
 
253
  return None, "Please upload an image."
254
  try:
255
  progress(0.1, desc="Loading TripoSG...")
 
 
 
 
 
 
256
  pipe, rmbg_net = load_triposg()
257
 
258
  img = Image.fromarray(input_image).convert("RGB")
requirements.txt CHANGED
@@ -10,7 +10,7 @@ numpy>=2
10
  # in pip>=21 isolated builds. Fix: --no-build-isolation at runtime.
11
  # - nvdiffrast/diso/detectron2 require nvcc (NVIDIA CUDA compiler) which is only
12
  # available in the ZeroGPU runtime container, not the Docker build stage.
13
- triposg @ git+https://github.com/VAST-AI-Research/TripoSG.git@fc5c40990181e2a756c4e0b1c2f4d6b5202faf8c
14
  clip @ git+https://github.com/openai/CLIP.git@d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
15
  # mvadapter and stablenormal use over-pinned deps (opencv-python vs headless, diffusers==0.28.0)
16
  # installed at runtime with --no-deps in app.py
 
10
  # in pip>=21 isolated builds. Fix: --no-build-isolation at runtime.
11
  # - nvdiffrast/diso/detectron2 require nvcc (NVIDIA CUDA compiler) which is only
12
  # available in the ZeroGPU runtime container, not the Docker build stage.
13
+ # triposg has no setup.py — cloned at runtime in app.py and added to sys.path
14
  clip @ git+https://github.com/openai/CLIP.git@d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
15
  # mvadapter and stablenormal use over-pinned deps (opencv-python vs headless, diffusers==0.28.0)
16
  # installed at runtime with --no-deps in app.py