Support external FunCaptcha ONNX fallback

This commit is contained in:
Hua
2026-03-12 19:53:51 +08:00
parent 221af67bf4
commit 201e517b86
7 changed files with 181 additions and 13 deletions

View File

@@ -484,11 +484,23 @@ uv run python cli.py predict image.png --type normal # 跳过分类直接
uv run python cli.py predict image.png --type 3d_rotate # 指定为旋转类型
uv run python cli.py predict-dir ./test_images/ # 批量识别
uv run python cli.py predict-funcaptcha challenge.jpg --question 4_3d_rollball_animals
FUNCAPTCHA_ROLLBALL_MODEL_PATH=/path/to/4_3d_rollball_animals.onnx \
uv run python cli.py predict-funcaptcha challenge.jpg --question 4_3d_rollball_animals
# 启动 HTTP 服务 (需先安装 server 可选依赖)
uv run python cli.py serve --port 8080
```
FunCaptcha 专项 ONNX 查找顺序:
- `onnx_models/funcaptcha_rollball_animals.onnx`
- 环境变量 `FUNCAPTCHA_ROLLBALL_MODEL_PATH`
- 默认回退 `/mnt/data/code/python/funcaptcha-server/model/4_3d_rollball_animals.onnx`
注意:
- `models/` 目录用于 Python 源码,不放 ONNX 产物
- 本仓库导出的 FunCaptcha ONNX 会携带 sidecar metadata 并使用 centered RGB 预处理
- 外部兼容 ONNX 若无 metadata推理层需回退到 `funcaptcha-server``/255.0` RGB 预处理契约
## HTTP 服务 (server.py可选)
纯推理服务,不依赖 torch / 训练代码,仅需 onnxruntime + FastAPI。