From 14d010d7dae61bc6deab693677258d312d464acc Mon Sep 17 00:00:00 2001 From: caoshihao996 <31568571+caoshihao996@users.noreply.github.com> Date: Mon, 19 Aug 2024 18:47:26 +0800 Subject: [PATCH 1/2] Fix yolov8.cpp larger object boundingbox error Yolov8 has three different heads and output different size feature maps. So the part of boundingboxs needs to be adjusted accordingly. --- examples/yolov8.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/yolov8.cpp b/examples/yolov8.cpp index 5b3926582c8..3a2e6cd0c88 100644 --- a/examples/yolov8.cpp +++ b/examples/yolov8.cpp @@ -187,6 +187,21 @@ static void parse_yolov8_detections( float w = *bboxes_ptr++; float h = *bboxes_ptr; + if (i >= 6400 && i < 8000) + { + x *= 2; + y *= 2; + w *= 2; + h *= 2; + } + else if (i >= 8000 && i < 8400) + { + x *= 4; + y *= 4; + w *= 4; + h *= 4; + } + float x0 = clampf((x - 0.5f * w), 0.f, (float)infer_img_width); float y0 = clampf((y - 0.5f * h), 0.f, (float)infer_img_height); float x1 = clampf((x + 0.5f * w), 0.f, (float)infer_img_width); From 518aa67827945c55231e286f41161b1b4a444f07 Mon Sep 17 00:00:00 2001 From: caoshihao996 <31568571+caoshihao996@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:20:19 +0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: nihui --- examples/yolov8.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/yolov8.cpp b/examples/yolov8.cpp index 3a2e6cd0c88..0997fc3312a 100644 --- a/examples/yolov8.cpp +++ b/examples/yolov8.cpp @@ -187,14 +187,14 @@ static void parse_yolov8_detections( float w = *bboxes_ptr++; float h = *bboxes_ptr; - if (i >= 6400 && i < 8000) + if (i >= 6400 && i < 8000) { x *= 2; y *= 2; w *= 2; h *= 2; } - else if (i >= 8000 && i < 8400) + else if (i >= 8000 && i < 8400) { x *= 4; y *= 4;