fix: resolve ONNX CUDA fallback, Docker e2e infrastructure, and all test failures

- Add safe_onnx_session() to gpu.py with graceful CUDA EP → CPU fallback
- Replace bare ort.InferenceSession() calls across colorize, restore, inpaint, remove_bg
- Add libcublas-12-6 to production Dockerfile for ONNX Runtime CUDA EP
- Add skipIfFeatureNotInstalled guards to remove-bg, blur-faces, smart-crop, ocr, noise-removal e2e specs
- Add AI tool install prompt detection in tools-all.spec.ts
- Add smart-crop to PYTHON_SIDECAR_TOOLS so frontend shows install prompt correctly
- Create Dockerfile.test.dockerignore to include tests/ in test image builds
- Add libheif-examples and exiftool to Dockerfile.test for HEIC and metadata tests
- Regenerate visual regression baselines for Docker/Linux and skip on non-Docker platforms
This commit is contained in:
ashim-hq
2026-04-20 20:53:54 +08:00
parent f67a03bb36
commit 37277e5c09
23 changed files with 203 additions and 94 deletions
+17
View File
@@ -55,3 +55,20 @@ def onnx_providers():
if gpu_available():
return ["CUDAExecutionProvider", "CPUExecutionProvider"]
return ["CPUExecutionProvider"]
def safe_onnx_session(model_path, providers=None):
"""Create an ONNX Runtime InferenceSession with graceful CUDA EP fallback."""
import onnxruntime as ort
if providers is None:
providers = onnx_providers()
try:
return ort.InferenceSession(model_path, providers=providers)
except Exception as e:
if "CUDAExecutionProvider" in providers:
print(f"[gpu] CUDA EP init failed ({e}), falling back to CPU",
file=sys.stderr, flush=True)
return ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
raise