Update app.py
Browse files
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 |
-
# =====
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 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,
|