Steewee98 commited on
Commit
5d8dff5
·
verified ·
1 Parent(s): 6047a0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -232,25 +232,26 @@ def build_args_list_for_test(d16_batch_path: str,
232
  args.extend([flag, str(v)])
233
  return args
234
 
235
- # ===== 新增:ZeroGPU 后按需安装 Pytorch-Correlation-extension =====
236
-
237
- def ensure_correlation_extension_installed():
238
- """Install spatial_correlation_sampler at runtime (needs CUDA)."""
239
- try:
240
- import spatial_correlation_sampler
241
- return
242
- except ImportError:
243
- pass
244
- print("[INFO] Installing spatial-correlation-sampler via pip (needs CUDA)...")
245
- subprocess.run(
246
- [sys.executable, "-m", "pip", "install", "spatial-correlation-sampler"],
247
- check=True
248
- )
249
- importlib.invalidate_caches()
250
- import spatial_correlation_sampler # verify
251
- print("[INFO] spatial-correlation-sampler installed successfully.")
252
-
253
  # ----------------- GRADIO HANDLER -----------------
 
254
  @spaces.GPU(duration=120) # 确保 CUDA 初始化在此函数体内
255
  def gradio_infer(
256
  debug_shapes,
 
232
  args.extend([flag, str(v)])
233
  return args
234
 
235
+ # ===== ZeroGPU: install spatial-correlation-sampler at runtime =====
236
+
237
+ def ensure_correlation_extension_installed():
238
+ """Install spatial_correlation_sampler at runtime (needs CUDA)."""
239
+ try:
240
+ import spatial_correlation_sampler
241
+ return
242
+ except ImportError:
243
+ pass
244
+ print("[INFO] Installing spatial-correlation-sampler via pip (needs CUDA)...")
245
+ subprocess.run(
246
+ [sys.executable, "-m", "pip", "install", "spatial-correlation-sampler"],
247
+ check=True
248
+ )
249
+ importlib.invalidate_caches()
250
+ import spatial_correlation_sampler # verify
251
+ print("[INFO] spatial-correlation-sampler installed successfully.")
252
+
253
  # ----------------- GRADIO HANDLER -----------------
254
+
255
  @spaces.GPU(duration=120) # 确保 CUDA 初始化在此函数体内
256
  def gradio_infer(
257
  debug_shapes,