fix: audit fixes for cross-platform correctness

- Fix NameError in restore.py: face enhancement loop used undefined
  variable `i`, now uses enumerate()
- Fix gpu.py ONNX fallback: previous smoke-test with empty bytes
  always raised, making GPU detection unreachable via the ONNX path.
  Now uses nvidia-smi hardware check after confirming CUDA EP is
  compiled in — works on Linux, Windows, and gracefully fails on macOS
- Fix cpu_fallback_packages stripping CUDA-specific index URLs when
  replacing paddlepaddle-gpu with paddlepaddle for CPU-only systems

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ashim
2026-04-20 15:28:35 +08:00
co-authored by Claude Opus 4.6
parent 01d30cfb61
commit 39e27635c8
3 changed files with 20 additions and 23 deletions
+5 -2
View File
@@ -90,8 +90,11 @@ def cpu_fallback_packages(packages: list[str]) -> list[str]:
name = pkg.split("==")[0].split(">=")[0].split("[")[0].strip()
if name in replacements:
version = pkg[len(name):] # e.g. "==1.20.1"
result.append(replacements[name] + version)
# Extract only the version spec, drop any inline flags
# (e.g. "--extra-index-url https://...cu126/" is GPU-specific)
tokens = pkg.split()
version_token = tokens[0][len(name):] # e.g. ">=3.2.1"
result.append(replacements[name] + version_token)
else:
result.append(pkg)
return result