debug: print YOLO output values and max confidence
This commit is contained in:
@@ -885,6 +885,13 @@ func (h *Handler) detectYOLO(modelName, imageBase64 string) (*DetectionResult, e
|
|||||||
return nil, err
|
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]
|
// YOLO11 输出: [1, 5, 8400] 或 [1, 84, 8400]
|
||||||
// 需要转置 + NMS 后处理,坐标从 640x640 缩放到原图尺寸
|
// 需要转置 + NMS 后处理,坐标从 640x640 缩放到原图尺寸
|
||||||
// 对于小图片(order 提示图)使用更低的置信度阈值
|
// 对于小图片(order 提示图)使用更低的置信度阈值
|
||||||
@@ -972,6 +979,9 @@ func postprocessYOLO(output []float32, origW, origH int, confThresh, nmsThresh f
|
|||||||
|
|
||||||
detections := []YOLODetection{}
|
detections := []YOLODetection{}
|
||||||
|
|
||||||
|
// 记录最大置信度用于调试
|
||||||
|
maxConf := 0.0
|
||||||
|
|
||||||
// 遍历所有检测框
|
// 遍历所有检测框
|
||||||
for i := 0; i < numBoxes; i++ {
|
for i := 0; i < numBoxes; i++ {
|
||||||
// YOLO11 输出是 [features, boxes],需要转置访问
|
// YOLO11 输出是 [features, boxes],需要转置访问
|
||||||
@@ -984,6 +994,10 @@ func postprocessYOLO(output []float32, origW, origH int, confThresh, nmsThresh f
|
|||||||
}
|
}
|
||||||
confidence := float64(output[confIdx])
|
confidence := float64(output[confIdx])
|
||||||
|
|
||||||
|
if confidence > maxConf {
|
||||||
|
maxConf = confidence
|
||||||
|
}
|
||||||
|
|
||||||
if confidence < confThresh {
|
if confidence < confThresh {
|
||||||
continue
|
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
|
// NMS
|
||||||
return nms(detections, nmsThresh)
|
return nms(detections, nmsThresh)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user