ncnn Yolov5s(V5) converted strange

fykwrbwg  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(50)

Hello, I am following https://github.com/midasklr/yolov5prune and trained yolov5s. After that I converted best.pt to best.onnx and also simplified best.onnx to best_sim.onnx.
Using ncnn ncnn2onnx I was able to convert best_sim.onnx. After replacing crop layers into YoloV5Focus layer, I used ncnnoptimize to clean up the ncnn.param and ncnn.bin files.
Problem is first few conv layers' w/b tensor values are uint8 as shown below figure (ncnn.param: first conv layers' weight tensor values are captured, also onnx tensor type says it is float16).

I did not add anything in conversion code. DEfault conversion should be float32 right?
So I dont know what the problem is.
here is part of original ncnn.param:

7767517
234 267
Input            images                   0 1 images
Split            splitncnn_input0         1 4 images images_splitncnn_0 images_splitncnn_1 images_splitncnn_2 images_splitncnn_3
MemoryData       1039                     0 1 1039
MemoryData       1045                     0 1 1045
MemoryData       1051                     0 1 1051
MemoryData       703                      0 1 703
MemoryData       764                      0 1 764
MemoryData       825                      0 1 825
Crop             Slice_4                  1 1 images_splitncnn_3 367 -23309=1,0 -23310=1,2147483647 -23311=1,1
Crop             Slice_9                  1 1 367 372 -23309=1,0 -23310=1,2147483647 -23311=1,2
Crop             Slice_14                 1 1 images_splitncnn_2 377 -23309=1,1 -23310=1,2147483647 -23311=1,1
Crop             Slice_19                 1 1 377 382 -23309=1,0 -23310=1,2147483647 -23311=1,2
Crop             Slice_24                 1 1 images_splitncnn_1 387 -23309=1,0 -23310=1,2147483647 -23311=1,1
Crop             Slice_29                 1 1 387 392 -23309=1,1 -23310=1,2147483647 -23311=1,2
Crop             Slice_34                 1 1 images_splitncnn_0 397 -23309=1,1 -23310=1,2147483647 -23311=1,1
Crop             Slice_39                 1 1 397 402 -23309=1,1 -23310=1,2147483647 -23311=1,2
Concat           Concat_40                4 1 372 382 392 402 403 0=0
Convolution      Conv_41                  1 1 403 857 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

here is modified part of ncnn.param:

7767517
225 267
Input            images                   0 1 images
YoloV5Focus      focus                    1 1 images 403
MemoryData       1039                     0 1 1039
MemoryData       1045                     0 1 1045
MemoryData       1051                     0 1 1051
MemoryData       703                      0 1 703
MemoryData       764                      0 1 764
MemoryData       825                      0 1 825
Convolution      Conv_41                  1 1 403 857 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

first 8 conv layers' tensor values are look like above and rest of conv layers' tensor values are normal float values.
Any idea what is the problem? thanks

nc1teljy

nc1teljy1#

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn
In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档
Detailed reference documentation
https://github.com/pnnx/pnnx
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx

相关问题