转换后的ncnn模型检测速度慢了20倍(0.016s to 0.3s)ncnn模型里自带的example中所用的yolov5s模型也是0.3s左右

q35jwt9p  于 9个月前  发布在  其他
关注(0)|答案(6)|浏览(103)

error log | 日志或报错信息 | ログ

由于转换后的模型检测速度大幅下降,求大佬解答,寻求解决方案,以下是我已做的尝试:
尝试使用example里自带的yolov5s的ncnn模型和mobilenet_voc_ssd模型,测试detect函数运行时长,对同一张图片进行检测的时长都在0.3s左右。
在转为onnx步骤时未加dynamic参数,后续转ncnn模型没有报bug且调整reshape中0=-1后能够正常检测,但是检测速度为0.3s,原pytorch的pt模型测速度是0.016s,猜测是在转onnx时没有加dynamic参数的原因。于是加入dynamic参数后转为onnx模型,但在最后转ncnn模型时报错。报错如下:

  1. *****************************************************
  2. Shape not supported yet!
  3. Gather not supported yet!
  4. # axis=0
  5. Shape not supported yet!
  6. Gather not supported yet!
  7. # axis=0
  8. Shape not supported yet!
  9. Gather not supported yet!
  10. # axis=0
  11. Unsupported unsqueeze axes !
  12. Unsupported unsqueeze axes !
  13. Unsupported unsqueeze axes !
  14. Unknown data type 0
  15. Shape not supported yet!
  16. Gather not supported yet!
  17. # axis=0
  18. Shape not supported yet!
  19. Gather not supported yet!
  20. # axis=0
  21. Shape not supported yet!
  22. Gather not supported yet!
  23. # axis=0
  24. Unsupported unsqueeze axes !
  25. Unsupported unsqueeze axes !
  26. Unsupported unsqueeze axes !
  27. Unknown data type 0
  28. Shape not supported yet!
  29. Gather not supported yet!
  30. # axis=0
  31. Shape not supported yet!
  32. Gather not supported yet!
  33. # axis=0
  34. Shape not supported yet!
  35. Gather not supported yet!
  36. # axis=0
  37. Unsupported unsqueeze axes !
  38. Unsupported unsqueeze axes !
  39. Unsupported unsqueeze axes !
  40. Unknown data type 0
  41. ************************************
pxq42qpu

pxq42qpu1#

您好,我遇到了和您差不多的问题,使用别人训练好的模型载入就很快,自己训练了一个然后载入进去检测的就很慢,发现是

  1. ncnn::Mat out;
  2. net_extractor.extract("detection_out",out);

这行代码占用了很多时间
整个检测加画框一张图片要0.27s,这句话就占用0.25s
而我载入其他作者训练好的模型只需要0.03s
我的也是通过pytorch转到oonx到ncnn的bin和param的
望有大神指点一下!谢谢!

yk9xbfzb

yk9xbfzb2#

你好,我遇到了和你差不多的问题,然后用别人训练好的模型就很快,自己训练了一个输入检测的就很慢,发现是

  1. ncnn::Mat out;
  2. net_extractor.extract("detection_out",out);

行代码占用了很多 整个检测加画框这张图片要0.27s,这幅画面就占用0.25s 而我加载其他作者训练好的模型只需要 0.03s我的也是通过pytorch转到oonx到ncnn的bin和param的 期待有大神指点一下!谢谢!

您好,请问您是怎么调试的呢,我遇到了错误只能导出apk然后在手机上调试,感觉这样效率太低,有没有什么更快的办法。

kxkpmulp

kxkpmulp3#

error log | 日志或报错信息 | ログ

由于转换后的模型检测速度大幅下降,求大佬解答,寻求解决方案,以下是我已做的尝试: 尝试使用example里自带的yolov5s的ncnn模型和mobilenet_voc_ssd模型,测试detect函数运行时长,对同一张图片进行检测的时长都在0.3s左右。 在转为onnx步骤时未加dynamic参数,后续转ncnn模型没有报bug且调整reshape中0=-1后能够正常检测,但是检测速度为0.3s,原pytorch的pt模型测速度是0.016s,猜测是在转onnx时没有加dynamic参数的原因。于是加入dynamic参数后转为onnx模型,但在最后转ncnn模型时报错。报错如下:

  1. *****************************************************
  2. Shape not supported yet!
  3. Gather not supported yet!
  4. # axis=0
  5. Shape not supported yet!
  6. Gather not supported yet!
  7. # axis=0
  8. Shape not supported yet!
  9. Gather not supported yet!
  10. # axis=0
  11. Unsupported unsqueeze axes !
  12. Unsupported unsqueeze axes !
  13. Unsupported unsqueeze axes !
  14. Unknown data type 0
  15. Shape not supported yet!
  16. Gather not supported yet!
  17. # axis=0
  18. Shape not supported yet!
  19. Gather not supported yet!
  20. # axis=0
  21. Shape not supported yet!
  22. Gather not supported yet!
  23. # axis=0
  24. Unsupported unsqueeze axes !
  25. Unsupported unsqueeze axes !
  26. Unsupported unsqueeze axes !
  27. Unknown data type 0
  28. Shape not supported yet!
  29. Gather not supported yet!
  30. # axis=0
  31. Shape not supported yet!
  32. Gather not supported yet!
  33. # axis=0
  34. Shape not supported yet!
  35. Gather not supported yet!
  36. # axis=0
  37. Unsupported unsqueeze axes !
  38. Unsupported unsqueeze axes !
  39. Unsupported unsqueeze axes !
  40. Unknown data type 0
  41. ************************************

这是否是有些op不支持的问题?可以参考一下 这篇文章

展开查看全部
igsr9ssn

igsr9ssn4#

error log | 日志或报错信息 | ログ

由于转换后的模型检测速度大幅下降,求大佬解答,寻求解决方案,以下是我已做的尝试: 尝试使用example里自带的yolov5s的ncnn模型和mobilenet_voc_ssd模型,测试detect函数运行时长,对同一张图片进行检测的时长都在0.3s左右。 在转为onnx步骤时未加dynamic参数,后续转ncnn模型没有报bug且调整reshape中0=-1后能够正常检测,但是检测速度为0.3s,原pytorch的pt模型测速度是0.016s,猜测是在转onnx时没有加dynamic参数的原因。于是加入dynamic参数后转为onnx模型,但在最后转ncnn模型时报错。报错如下:

  1. *****************************************************
  2. Shape not supported yet!
  3. Gather not supported yet!
  4. # axis=0
  5. Shape not supported yet!
  6. Gather not supported yet!
  7. # axis=0
  8. Shape not supported yet!
  9. Gather not supported yet!
  10. # axis=0
  11. Unsupported unsqueeze axes !
  12. Unsupported unsqueeze axes !
  13. Unsupported unsqueeze axes !
  14. Unknown data type 0
  15. Shape not supported yet!
  16. Gather not supported yet!
  17. # axis=0
  18. Shape not supported yet!
  19. Gather not supported yet!
  20. # axis=0
  21. Shape not supported yet!
  22. Gather not supported yet!
  23. # axis=0
  24. Unsupported unsqueeze axes !
  25. Unsupported unsqueeze axes !
  26. Unsupported unsqueeze axes !
  27. Unknown data type 0
  28. Shape not supported yet!
  29. Gather not supported yet!
  30. # axis=0
  31. Shape not supported yet!
  32. Gather not supported yet!
  33. # axis=0
  34. Shape not supported yet!
  35. Gather not supported yet!
  36. # axis=0
  37. Unsupported unsqueeze axes !
  38. Unsupported unsqueeze axes !
  39. Unsupported unsqueeze axes !
  40. Unknown data type 0
  41. ************************************

这是否是有些op不支持的问题?可以参考一下 这篇文章

惊了,这个牛逼

展开查看全部
hmtdttj4

hmtdttj45#

Has anyone solved this problem? I encountered a similar problem.

8fq7wneg

8fq7wneg6#

您好,我遇到了和您差不多的问题,使用别人训练好的模型载入就很快,自己训练了一个然后载入进去检测的就很慢,发现是

  1. ncnn::Mat out;
  2. net_extractor.extract("detection_out",out);

这行代码占用了很多时间 整个检测加画框一张图片要0.27s,这句话就占用0.25s 而我载入其他作者训练好的模型只需要0.03s 我的也是通过pytorch转到oonx到ncnn的bin和param的 望有大神指点一下!谢谢!

你好,请问这个问题你发现问题是出在哪里了吗?我也遇到了同样的问题,如果方便的话麻烦指点下。

相关问题