From e2ac2fbfcce2ed71aeab7290406a5ff325ad5997 Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 17 Jul 2026 14:43:59 +0000 Subject: [PATCH] debug: print YOLO output values and max confidence --- internal/captcha/handler.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/captcha/handler.go b/internal/captcha/handler.go index 6a0186d..f8a417d 100644 --- a/internal/captcha/handler.go +++ b/internal/captcha/handler.go @@ -885,6 +885,13 @@ func (h *Handler) detectYOLO(modelName, imageBase64 string) (*DetectionResult, e return nil, err } + // DEBUG: 打印 ONNX 输出的前 20 个值 + fmt.Printf("DEBUG YOLO output first 20 values: ") + for i := 0; i < 20 && i < len(output); i++ { + fmt.Printf("%.4f ", output[i]) + } + fmt.Println() + // YOLO11 输出: [1, 5, 8400] 或 [1, 84, 8400] // 需要转置 + NMS 后处理,坐标从 640x640 缩放到原图尺寸 // 对于小图片(order 提示图)使用更低的置信度阈值 @@ -972,6 +979,9 @@ func postprocessYOLO(output []float32, origW, origH int, confThresh, nmsThresh f detections := []YOLODetection{} + // 记录最大置信度用于调试 + maxConf := 0.0 + // 遍历所有检测框 for i := 0; i < numBoxes; i++ { // YOLO11 输出是 [features, boxes],需要转置访问 @@ -984,6 +994,10 @@ func postprocessYOLO(output []float32, origW, origH int, confThresh, nmsThresh f } confidence := float64(output[confIdx]) + if confidence > maxConf { + maxConf = confidence + } + if confidence < confThresh { continue } @@ -1032,6 +1046,8 @@ func postprocessYOLO(output []float32, origW, origH int, confThresh, nmsThresh f }) } + fmt.Printf("DEBUG YOLO postprocess: outputLen=%d, numFeatures=%d, maxConf=%.4f, found=%d\n", outputLen, numFeatures, maxConf, len(detections)) + // NMS return nms(detections, nmsThresh) }