Align task API and add FunCaptcha support

This commit is contained in:
Hua
2026-03-12 19:32:59 +08:00
parent ef9518deeb
commit bc6776979e
33 changed files with 3446 additions and 672 deletions

View File

@@ -0,0 +1,33 @@
"""
ONNX 模型 sidecar metadata 辅助工具。
"""
from __future__ import annotations
import json
from pathlib import Path
def model_metadata_path(model_path: str | Path) -> Path:
return Path(model_path).with_suffix(".meta.json")
def write_model_metadata(model_path: str | Path, metadata: dict) -> Path:
path = model_metadata_path(model_path)
payload = {
"version": 1,
**metadata,
}
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", encoding="utf-8") as f:
json.dump(payload, f, ensure_ascii=True, indent=2, sort_keys=True)
f.write("\n")
return path
def load_model_metadata(model_path: str | Path) -> dict | None:
path = model_metadata_path(model_path)
if not path.exists():
return None
with path.open("r", encoding="utf-8") as f:
return json.load(f)