From 2f4001b6a961113b9838678ca56ab8fbfa7d98fc Mon Sep 17 00:00:00 2001 From: fengyuentau Date: Wed, 23 Dec 2020 20:37:57 +0800 Subject: [PATCH] FIX: add clamp for iou_score --- src/facedetectcnn.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/facedetectcnn.cpp b/src/facedetectcnn.cpp index 34ec6be28..00b8c67ae 100644 --- a/src/facedetectcnn.cpp +++ b/src/facedetectcnn.cpp @@ -871,7 +871,15 @@ bool detection_output(const CDataBlob * priorbox, float cls_score = pConf[i + 1]; int face_idx = i / 2; float iou_score = pIoU[face_idx]; + // clamp + if (iou_score < 0.f) { + iou_score = 0.f; + } + else if (iou_score > 1.f) { + iou_score = 1.f; + } float conf = sqrtf(cls_score * iou_score); + if(conf > confidence_threshold) { float fBox_x1 = pPriorBox[face_idx * 4];