Files
Hermes 68f181e0ac
Build and Deploy / build (push) Failing after 3m8s
Build and Deploy / deploy (push) Skipped
fix: 相似度改走双输出 Siamese(对齐上游 AntiCAP),阴影滑块补尺寸校验
对照上游 https://github.com/81NewArk/AntiCAP 逐项核对后修两处:

1) 相似度(internal/captcha/handler.go + pkg/onnx)
   上游是 outputs = session.run(None, feed); emb1, emb2 = outputs[0], outputs[1]
   —— 模型本身分别吐出两路 embedding。
   旧实现只 run 了 1 个输出(onnx.cpp 里 Run 的 output_count = 1),
   再把这个张量从中间切成两半当两个 embedding,
   实测四组完全不同的输入返回同一个值(0.49188173),等于接口失效。
   现在新增 onnx_run_dual_input_two_outputs 取前两个输出,
   两路各算 L2 距离后 1/(1+dist);单输出模型保留旧路径回退并打日志。

2) 阴影滑块(pkg/opencv + internal/handler)
   上游 solve_slider_comparison 要求 target 与 background 同尺寸
   (PIL ImageChops.difference 的硬前提),旧实现不校验,
   尺寸不同时直接抛 OpenCV -209 尺寸不匹配,返回 500。
   现在前置校验并返回 400 + 明确原因;SliderMatch 也补了「滑块不能大于背景」的校验。

预处理与旋转逻辑核对结论:preprocessSiamese(105×105 / ImageNet norm)与
preprocessRotation(正方形中心裁剪 + h/√2 + 224 / ImageNet norm)与上游一致,未改。
2026-12-03 08:23:51 +08:00
..