ncnn-android-yolov5 icon indicating copy to clipboard operation
ncnn-android-yolov5 copied to clipboard

How to convert yolov5 to NCNN?

Open ForestWang opened this issue 4 years ago • 13 comments

Hi nihui:

as I as know, there is some ops that NCNN doesn't support,so how do you convert it to NCNN,thanks very much.

ForestWang avatar Nov 06 '20 01:11 ForestWang

refer https://zhuanlan.zhihu.com/p/275989233 (in chinese)

nihui avatar Nov 06 '20 08:11 nihui

After I modified the param file, the following information appeared using ncnnoptimize. Does anyone know how to solve it?

layer YoloV5Focus not exists or registered 段错误 (核心已转储)

zxj11838 avatar Nov 11 '20 08:11 zxj11838

After I modified the param file, the following information appeared using ncnnoptimize. Does anyone know how to solve it?

layer YoloV5Focus not exists or registered 段错误 (核心已转储)

  1. Replace your custom layer YoloV5Focus with a known builtin layer, such as Exp
  2. Run ncnnoptimize
  3. Change Exp back to YoloV5Focus in the optimized param

nihui avatar Nov 11 '20 11:11 nihui

refer https://zhuanlan.zhihu.com/p/275989233 (in chinese)

many thanks!

ForestWang avatar Nov 12 '20 03:11 ForestWang

I change the param like this Input images 0 1 images Exp focus 1 1 images 207 Convolution Conv_41 1 1 207 208 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=3456

and run ./ncnnoptimize onnx/yolov5s.param onnx/yolov5s.bin yolov5s-opt.param yolov5s-opt.bin 65536 but failed,there is the information

Input layer images without shape info, shape_inference aborted

Anyone know how to solve it?

yao-zheng-yi avatar Nov 12 '20 10:11 yao-zheng-yi

I have the same problem. The generated file cannot be used in the android project.

zxj11838 avatar Nov 12 '20 10:11 zxj11838

the same question

suyali avatar Nov 13 '20 09:11 suyali

the same question for me. but the opt param and bin files are still generated. However, the detection performance is poor comparing to yolov5s.pt.

jjqtony avatar Dec 08 '20 02:12 jjqtony

refer https://zhuanlan.zhihu.com/p/275989233 (in chinese)

我从pytorch hub上下载了yolov5s.pt,这个pt我测试了,工作正常。然后严格按照这篇文章的做法生成了param和bin文件,替换您的安卓项目中的相应文件,生成了apk,手机上可以正常安装,也能运行,但识别率跟原始的pt差距很大,也跟您安卓项目提供的param和bin文件差距很大,很多近处的人物都识别不出来。用文本编辑器打开您安卓项目中的param文件和我生成的param文件,比较发现,前面部分都一样,后面有一些差别。请问这是什么原因?需要您的帮助!

jjqtony avatar Dec 08 '20 03:12 jjqtony

最新版本ncnn的ncnnoptimize已经支持自定义op了

nihui avatar Dec 18 '20 16:12 nihui

Refer to this website (https://zhuanlan.zhihu.com/p/275989233) . Do I need to change the Focus to remove the slice array operation under common.py when generating the onnx model?

zxj11838 avatar Jan 07 '21 03:01 zxj11838

I change the param like this Input images 0 1 images Exp focus 1 1 images 207 Convolution Conv_41 1 1 207 208 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=3456

and run ./ncnnoptimize onnx/yolov5s.param onnx/yolov5s.bin yolov5s-opt.param yolov5s-opt.bin 65536 but failed,there is the information

Input layer images without shape info, shape_inference aborted

Anyone know how to solve it?

@yao-zheng-yi Did you sovle it ? I have a same problem, how to fix it ?

Houangnt avatar Sep 29 '21 11:09 Houangnt

I change the param like this Input images 0 1 images Exp focus 1 1 images 207 Convolution Conv_41 1 1 207 208 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=3456

and run ./ncnnoptimize onnx/yolov5s.param onnx/yolov5s.bin yolov5s-opt.param yolov5s-opt.bin 65536 but failed,there is the information

Input layer images without shape info, shape_inference aborted

Anyone know how to solve it?

Do you sovle it? I also have the same problem, how to fix? Many thx!

LRY89757 avatar Mar 29 '22 16:03 LRY89757