fix: resolve all audit findings — e2e coverage, feature system hardening, visual baselines

- Add 8 new E2E specs for AI tools (upscale, enhance-faces, colorize,
  restore-photo, erase-object, smart-crop, passport-photo, red-eye-removal)
  closing all HIGH/MEDIUM coverage gaps from the test matrix audit
- Fix ensureAiDirs() crash on non-Docker environments by gating on
  isDockerEnvironment() — prevents ENOENT when /data doesn't exist
- Bump torch 2.6.0→2.7.0 and torchvision 0.21.0→0.22.0 in feature
  manifest for broader Python version compatibility
- Add Python 3.14 version guard warning in install_feature.py
- Remove duplicate torchvision shims from upscale.py and enhance_faces.py
  (dispatcher.py already handles this at startup)
- Remove orphaned tools.batch i18n key and dead pipeline-builder filter
- Regenerate 4 visual regression baselines for current UI state
- Add data-testid to passport-photo generate button for E2E testability
This commit is contained in:
ashim-hq
2026-04-20 18:47:59 +08:00
parent e7eea34080
commit f67a03bb36
20 changed files with 911 additions and 61 deletions
-28
View File
@@ -3,34 +3,6 @@ import sys
import json
import os
# Patch for basicsr compatibility with torchvision >= 0.17.
# torchvision removed transforms.functional_tensor, merging everything
# into transforms.functional. basicsr 1.4.2 still imports the old path
# (e.g. rgb_to_grayscale), so we create a proxy module that forwards
# ALL attribute lookups to the new location.
try:
import torchvision.transforms.functional_tensor # noqa: F401
except (ImportError, ModuleNotFoundError):
try:
import types
import torchvision.transforms.functional as _F
import torchvision.transforms
_shim = types.ModuleType("torchvision.transforms.functional_tensor")
_shim.__getattr__ = lambda name: getattr(_F, name)
# Pre-populate the attribute basicsr actually imports so that
# `from torchvision.transforms.functional_tensor import rgb_to_grayscale`
# works (from-import checks __dict__ before __getattr__).
_shim.rgb_to_grayscale = _F.rgb_to_grayscale
sys.modules["torchvision.transforms.functional_tensor"] = _shim
# The parent package must also reference the submodule for
# `from torchvision.transforms.functional_tensor import ...` to
# resolve correctly in all Python versions.
torchvision.transforms.functional_tensor = _shim
except (ImportError, AttributeError) as e:
print(f"[enhance-faces] torchvision shim failed: {e}", file=sys.stderr, flush=True)
def emit_progress(percent, stage):
"""Emit structured progress to stderr for bridge.ts to capture."""
+6 -1
View File
@@ -72,7 +72,7 @@ def cpu_fallback_packages(packages: list[str]) -> list[str]:
result = []
for pkg in packages:
# Handle multi-package CUDA torch entries like:
# "torch==2.6.0+cu126 torchvision==0.21.0+cu126 --index-url ..."
# "torch==2.7.0+cu126 torchvision==0.22.0+cu126 --index-url ..."
first_token = pkg.split()[0] if pkg.strip() else ""
if first_token.startswith("torch==") and "+cu" in first_token:
# Extract torch and torchvision versions, strip CUDA suffix
@@ -423,6 +423,11 @@ def write_installed_atomic(ai_dir: str, data: dict) -> None:
def main() -> None:
if sys.version_info >= (3, 14):
print(f"[WARN] Python {sys.version_info.major}.{sys.version_info.minor} detected. "
f"Some packages may not have pre-built wheels. Build from source may be attempted.",
file=sys.stderr, flush=True)
if len(sys.argv) < 4:
fail(
f"Usage: {sys.argv[0]} <bundleId> <manifestPath> <modelsDir>\n"
-28
View File
@@ -3,34 +3,6 @@ import sys
import json
import os
# Patch for basicsr compatibility with torchvision >= 0.17.
# torchvision removed transforms.functional_tensor, merging everything
# into transforms.functional. basicsr 1.4.2 still imports the old path
# (e.g. rgb_to_grayscale), so we create a proxy module that forwards
# ALL attribute lookups to the new location.
try:
import torchvision.transforms.functional_tensor # noqa: F401
except (ImportError, ModuleNotFoundError):
try:
import types
import torchvision.transforms.functional as _F
import torchvision.transforms
_shim = types.ModuleType("torchvision.transforms.functional_tensor")
_shim.__getattr__ = lambda name: getattr(_F, name)
# Pre-populate the attribute basicsr actually imports so that
# `from torchvision.transforms.functional_tensor import rgb_to_grayscale`
# works (from-import checks __dict__ before __getattr__).
_shim.rgb_to_grayscale = _F.rgb_to_grayscale
sys.modules["torchvision.transforms.functional_tensor"] = _shim
# The parent package must also reference the submodule for
# `from torchvision.transforms.functional_tensor import ...` to
# resolve correctly in all Python versions.
torchvision.transforms.functional_tensor = _shim
except (ImportError, AttributeError) as e:
print(f"[upscale] torchvision shim failed: {e}", file=sys.stderr, flush=True)
def emit_progress(percent, stage):
"""Emit structured progress to stderr for bridge.ts to capture."""
-1
View File
@@ -165,7 +165,6 @@ export const en = {
description: "Convert images to base64 strings for embedding in HTML, CSS, and more",
},
pipeline: { name: "Pipeline Builder", description: "Chain multiple tools into a workflow" },
batch: { name: "Batch Processing", description: "Apply any tool to multiple images" },
},
settings: {
title: "Settings",