整合去雾网页工具

This commit is contained in:
admin
2026-06-10 17:42:11 +08:00
commit 6db15ebc3f
101 changed files with 10167 additions and 0 deletions

12
scripts/clean_generated.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
find . -type d -name '__pycache__' -prune -exec rm -rf {} +
find . -type f \( -name '*.pyc' -o -name '*.pyo' -o -name 'Thumbs.db' -o -name '.DS_Store' \) -delete
rm -rf web_results
mkdir -p web_results
echo "Cleaned generated files."

58
scripts/verify_all.py Executable file
View File

@@ -0,0 +1,58 @@
from __future__ import annotations
import argparse
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "web_dehaze"))
import pipeline # noqa: E402
DEFAULT_METHODS = ["AOD", "Baidu_API", "DCP", "DehazeNet", "GCANet", "RefineDNet"]
def main() -> int:
parser = argparse.ArgumentParser(description="Verify dehaze models through the unified pipeline.")
parser.add_argument("--images", nargs="*", help="Image names under 待去雾图片/. Defaults to all images.")
parser.add_argument("--methods", nargs="*", default=DEFAULT_METHODS, help="Methods to run.")
parser.add_argument("--skip-baidu", action="store_true", help="Skip Baidu API calls.")
args = parser.parse_args()
images = args.images or [item["name"] for item in pipeline.list_images()]
methods = [m for m in args.methods if not (args.skip_baidu and m == "Baidu_API")]
caps = pipeline.capabilities()["methods"]
unavailable = [m for m in methods if not caps.get(m, {}).get("available")]
if unavailable:
print("Unavailable methods:", ", ".join(unavailable))
return 2
failures: list[tuple[str, str, str]] = []
for image in images:
print(f"\n=== {image} ===")
for method in methods:
start = time.time()
print(f"[RUN] {method}")
try:
result = pipeline.run_dehaze_method(image, method, {}, print)
elapsed = time.time() - start
print(f"[OK] {method}: {pipeline.relpath(result)} ({elapsed:.1f}s)")
except Exception as exc:
failures.append((image, method, str(exc)))
print(f"[FAIL] {method}: {exc}")
if failures:
print("\nFailures:")
for image, method, error in failures:
print(f"- {image} / {method}: {error}")
return 1
print("\nAll requested methods completed successfully.")
return 0
if __name__ == "__main__":
raise SystemExit(main())