ncnn icon indicating copy to clipboard operation
ncnn copied to clipboard

没有yolov8.cpp

Open WangShuai771216 opened this issue 1 year ago • 5 comments

ncnn量化后的yolov8模型模型文件,example目录下没有推理代码yolov8.cpp

WangShuai771216 avatar Jun 04 '24 07:06 WangShuai771216

wait for

cillayue avatar Jun 04 '24 09:06 cillayue

I just submitted a pull request for yolov8 example https://github.com/Tencent/ncnn/pull/5506 I hope it can be helpful to you.

whyb avatar Jun 12 '24 07:06 whyb

I just submitted a pull request for yolov8 example #5506 I hope it can be helpful to you.

Hi, I tested the yolov8.cpp example in your PR, but the results are unreasonable. Specifically, I got yolov8n.bin and yolov8n.param following your guide in yolov8.cpp, and your yolov8n example returns many detections with same confidence of 0.5. The result: image

Deephome avatar Jun 19 '24 09:06 Deephome

I just submitted a pull request for yolov8 example #5506 I hope it can be helpful to you.

Hi, I tested the yolov8.cpp example in your PR, but the results are unreasonable. Specifically, I got yolov8n.bin and yolov8n.param following your guide in yolov8.cpp, and your yolov8n example returns many detections with same confidence of 0.5. The result: image

我知道这个问题,这个原因不是因为我这边的原因,而是您导出的yolov8.ncnn.* 模型是仅固定支持[1,3,640,640]的模型,并不支持动态shape输入造成的。

这个错误的模型会导致输入进去的数据为了保持图像原比例缩放,并不符合模型要求的[1,3,640,640],实际上有可能是[1,3,640,540],所以模型内部会错位读取图像,对结果造成严重偏差。

只是要尝试效果的话,您可以直接把输入的图片用画图工具或者cv::resize() 修改成640x640的尺寸。

pnnx本身是支持动态shape输入的,您可以去参考 https://github.com/pnnx/pnnx?tab=readme-ov-file#------detailed-options

导出正确的支持动态shape输入的模型,期待您的好消息~🤣

whyb avatar Jun 19 '24 09:06 whyb

I just submitted a pull request for yolov8 example #5506 I hope it can be helpful to you.

Hi, I tested the yolov8.cpp example in your PR, but the results are unreasonable. Specifically, I got yolov8n.bin and yolov8n.param following your guide in yolov8.cpp, and your yolov8n example returns many detections with same confidence of 0.5. The result: image

我知道这个问题,这个原因不是因为我这边的原因,而是您导出的yolov8.ncnn.* 模型是仅固定支持[1,3,640,640]的模型,并不支持动态shape输入造成的。

这个错误的模型会导致输入进去的数据为了保持图像原比例缩放,并不符合模型要求的[1,3,640,640],实际上有可能是[1,3,640,540],所以模型内部会错位读取图像,对结果造成严重偏差。

只是要尝试效果的话,您可以直接把输入的图片用画图工具或者cv::resize() 修改成640x640的尺寸。

pnnx本身是支持动态shape输入的,您可以去参考 https://github.com/pnnx/pnnx?tab=readme-ov-file#------detailed-options

导出正确的支持动态shape输入的模型,期待您的好消息~🤣

Well, I find out that the problem originates from a bug in your yolov8.cpp the following lines:

    int wpad = (w + MAX_STRIDE - 1) / MAX_STRIDE * MAX_STRIDE - w;
    int hpad = (h + MAX_STRIDE - 1) / MAX_STRIDE * MAX_STRIDE - h;

should be modified as:

    int wpad = (target_size + MAX_STRIDE - 1) / MAX_STRIDE * MAX_STRIDE - w;
    int hpad = (target_size + MAX_STRIDE - 1) / MAX_STRIDE * MAX_STRIDE - h;

Deephome avatar Jun 19 '24 10:06 Deephome

close for https://github.com/Tencent/ncnn/pull/5506

nihui avatar Aug 19 '24 03:08 nihui

hi, yolov8 examples are updated with full support for detection, segmentation, classification, pose estimation and obb https://github.com/Tencent/ncnn/tree/master/examples

android demo https://github.com/nihui/ncnn-android-yolov8

detailed instruction (zh) https://zhuanlan.zhihu.com/p/16030630352

nihui avatar Jan 08 '25 08:01 nihui