yolov5 训练一个模型,转成fp16用NCNN部署到移动端,发现ncnn侧得分超低,并位置都不对

svdrlsy4  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(54)

1.yolov5 训练一个车牌检测模型,转成fp16用NCNN部署到移动端
python3 export.py --weights /yolo/yolov5/weights/best.pt --include onnx --train
python3 export.py --weights /yolo/yolov5/weights/best.pt --img 320 --include onnx --train
python3 -m onnxsim /yolo/yolov5/weights/best.onnx /yolo/yolov5/weights/best-sim.onnx
./weights/onnx2ncnn /yolo/yolov5/weights/best-sim.onnx /yolo/yolov5/weights/best.param /yolo/yolov5/weights/best.bin
./weights/ncnnoptimize /yolo/yolov5/weights/best.param /yolo/yolov5/weights/best.bin /yolo/yolov5/weights/best-opt.param /yolo/yolov5/weights/best-opt.bin 65536

2.在安卓用NCNN部署
修改了:以下参数匹配模型输出参数
ex.input("images", in_pad);
ex.extract("output", out);
ex.extract("353", out);
ex.extract("367", out);
参数匹配yolov5n的训练参数

发现同一张图片(车牌做了打码处理)在ncnn侧得分超低,并位置都不对!
云端检测得分

NCNN检测得分

pvabu6sv

pvabu6sv1#

补充说明:
1.云端是用1080P的图片训练 imgsize是320
2.NCNN用320检测1080P的图片
3. param如下:

7767517
173 197
Input images 0 1 images
Convolution Conv_0 1 1 images 122 0=16 1=6 3=2 4=2 5=1 6=1728
Swish Mul_2 1 1 122 124
Convolution Conv_3 1 1 124 125 0=32 1=3 3=2 4=1 5=1 6=4608
Swish Mul_5 1 1 125 127
Split splitncnn_0 1 2 127 127_splitncnn_0 127_splitncnn_1
Convolution Conv_6 1 1 127_splitncnn_1 128 0=16 1=1 5=1 6=512
Swish Mul_8 1 1 128 130
Split splitncnn_1 1 2 130 130_splitncnn_0 130_splitncnn_1
Convolution Conv_9 1 1 130_splitncnn_1 131 0=16 1=1 5=1 6=256
Swish Mul_11 1 1 131 133
Convolution Conv_12 1 1 133 134 0=16 1=3 4=1 5=1 6=2304
Swish Mul_14 1 1 134 136
BinaryOp Add_15 2 1 130_splitncnn_0 136 137
Convolution Conv_16 1 1 127_splitncnn_0 138 0=16 1=1 5=1 6=512
Swish Mul_18 1 1 138 140
Concat Concat_19 2 1 137 140 141
Convolution Conv_20 1 1 141 142 0=32 1=1 5=1 6=1024
Swish Mul_22 1 1 142 144
Convolution Conv_23 1 1 144 145 0=64 1=3 3=2 4=1 5=1 6=18432
Swish Mul_25 1 1 145 147
Split splitncnn_2 1 2 147 147_splitncnn_0 147_splitncnn_1
Convolution Conv_26 1 1 147_splitncnn_1 148 0=32 1=1 5=1 6=2048
Swish Mul_28 1 1 148 150
Split splitncnn_3 1 2 150 150_splitncnn_0 150_splitncnn_1
Convolution Conv_29 1 1 150_splitncnn_1 151 0=32 1=1 5=1 6=1024
Swish Mul_31 1 1 151 153
Convolution Conv_32 1 1 153 154 0=32 1=3 4=1 5=1 6=9216
Swish Mul_34 1 1 154 156
BinaryOp Add_35 2 1 150_splitncnn_0 156 157
Split splitncnn_4 1 2 157 157_splitncnn_0 157_splitncnn_1
Convolution Conv_36 1 1 157_splitncnn_1 158 0=32 1=1 5=1 6=1024
Swish Mul_38 1 1 158 160
Convolution Conv_39 1 1 160 161 0=32 1=3 4=1 5=1 6=9216
Swish Mul_41 1 1 161 163
BinaryOp Add_42 2 1 157_splitncnn_0 163 164
Convolution Conv_43 1 1 147_splitncnn_0 165 0=32 1=1 5=1 6=2048
Swish Mul_45 1 1 165 167
Concat Concat_46 2 1 164 167 168
Convolution Conv_47 1 1 168 169 0=64 1=1 5=1 6=4096
Swish Mul_49 1 1 169 171
Split splitncnn_5 1 2 171 171_splitncnn_0 171_splitncnn_1
Convolution Conv_50 1 1 171_splitncnn_1 172 0=128 1=3 3=2 4=1 5=1 6=73728
Swish Mul_52 1 1 172 174
Split splitncnn_6 1 2 174 174_splitncnn_0 174_splitncnn_1
Convolution Conv_53 1 1 174_splitncnn_1 175 0=64 1=1 5=1 6=8192
Swish Mul_55 1 1 175 177
Split splitncnn_7 1 2 177 177_splitncnn_0 177_splitncnn_1
Convolution Conv_56 1 1 177_splitncnn_1 178 0=64 1=1 5=1 6=4096
Swish Mul_58 1 1 178 180
Convolution Conv_59 1 1 180 181 0=64 1=3 4=1 5=1 6=36864
Swish Mul_61 1 1 181 183
BinaryOp Add_62 2 1 177_splitncnn_0 183 184
Split splitncnn_8 1 2 184 184_splitncnn_0 184_splitncnn_1
Convolution Conv_63 1 1 184_splitncnn_1 185 0=64 1=1 5=1 6=4096
Swish Mul_65 1 1 185 187
Convolution Conv_66 1 1 187 188 0=64 1=3 4=1 5=1 6=36864
Swish Mul_68 1 1 188 190
BinaryOp Add_69 2 1 184_splitncnn_0 190 191
Split splitncnn_9 1 2 191 191_splitncnn_0 191_splitncnn_1
Convolution Conv_70 1 1 191_splitncnn_1 192 0=64 1=1 5=1 6=4096
Swish Mul_72 1 1 192 194
Convolution Conv_73 1 1 194 195 0=64 1=3 4=1 5=1 6=36864
Swish Mul_75 1 1 195 197
BinaryOp Add_76 2 1 191_splitncnn_0 197 198
Convolution Conv_77 1 1 174_splitncnn_0 199 0=64 1=1 5=1 6=8192
Swish Mul_79 1 1 199 201
Concat Concat_80 2 1 198 201 202
Convolution Conv_81 1 1 202 203 0=128 1=1 5=1 6=16384
Swish Mul_83 1 1 203 205
Split splitncnn_10 1 2 205 205_splitncnn_0 205_splitncnn_1
Convolution Conv_84 1 1 205_splitncnn_1 206 0=256 1=3 3=2 4=1 5=1 6=294912
Swish Mul_86 1 1 206 208
Split splitncnn_11 1 2 208 208_splitncnn_0 208_splitncnn_1
Convolution Conv_87 1 1 208_splitncnn_1 209 0=128 1=1 5=1 6=32768
Swish Mul_89 1 1 209 211
Split splitncnn_12 1 2 211 211_splitncnn_0 211_splitncnn_1
Convolution Conv_90 1 1 211_splitncnn_1 212 0=128 1=1 5=1 6=16384
Swish Mul_92 1 1 212 214
Convolution Conv_93 1 1 214 215 0=128 1=3 4=1 5=1 6=147456
Swish Mul_95 1 1 215 217
BinaryOp Add_96 2 1 211_splitncnn_0 217 218
Convolution Conv_97 1 1 208_splitncnn_0 219 0=128 1=1 5=1 6=32768
Swish Mul_99 1 1 219 221
Concat Concat_100 2 1 218 221 222
Convolution Conv_101 1 1 222 223 0=256 1=1 5=1 6=65536
Swish Mul_103 1 1 223 225
Convolution Conv_104 1 1 225 226 0=128 1=1 5=1 6=32768
Swish Mul_106 1 1 226 228
Split splitncnn_13 1 2 228 228_splitncnn_0 228_splitncnn_1
Pooling MaxPool_107 1 1 228_splitncnn_1 229 1=5 3=2 5=1
Split splitncnn_14 1 2 229 229_splitncnn_0 229_splitncnn_1
Pooling MaxPool_108 1 1 229_splitncnn_1 230 1=5 3=2 5=1
Split splitncnn_15 1 2 230 230_splitncnn_0 230_splitncnn_1
Pooling MaxPool_109 1 1 230_splitncnn_1 231 1=5 3=2 5=1
Concat Concat_110 4 1 228_splitncnn_0 229_splitncnn_0 230_splitncnn_0 231 232
Convolution Conv_111 1 1 232 233 0=256 1=1 5=1 6=131072
Swish Mul_113 1 1 233 235
Convolution Conv_114 1 1 235 236 0=128 1=1 5=1 6=32768
Swish Mul_116 1 1 236 238
Split splitncnn_16 1 2 238 238_splitncnn_0 238_splitncnn_1
Interp Resize_121 1 1 238_splitncnn_1 243 0=1 1=2.000000e+00 2=2.000000e+00
Concat Concat_122 2 1 243 205_splitncnn_0 244
Split splitncnn_17 1 2 244 244_splitncnn_0 244_splitncnn_1
Convolution Conv_123 1 1 244_splitncnn_1 245 0=64 1=1 5=1 6=16384
Swish Mul_125 1 1 245 247
Convolution Conv_126 1 1 247 248 0=64 1=1 5=1 6=4096
Swish Mul_128 1 1 248 250
Convolution Conv_129 1 1 250 251 0=64 1=3 4=1 5=1 6=36864
Swish Mul_131 1 1 251 253
Convolution Conv_132 1 1 244_splitncnn_0 254 0=64 1=1 5=1 6=16384
Swish Mul_134 1 1 254 256
Concat Concat_135 2 1 253 256 257
Convolution Conv_136 1 1 257 258 0=128 1=1 5=1 6=16384
Swish Mul_138 1 1 258 260
Convolution Conv_139 1 1 260 261 0=64 1=1 5=1 6=8192
Swish Mul_141 1 1 261 263
Split splitncnn_18 1 2 263 263_splitncnn_0 263_splitncnn_1
Interp Resize_146 1 1 263_splitncnn_1 268 0=1 1=2.000000e+00 2=2.000000e+00
Concat Concat_147 2 1 268 171_splitncnn_0 269
Split splitncnn_19 1 2 269 269_splitncnn_0 269_splitncnn_1
Convolution Conv_148 1 1 269_splitncnn_1 270 0=32 1=1 5=1 6=4096
Swish Mul_150 1 1 270 272
Convolution Conv_151 1 1 272 273 0=32 1=1 5=1 6=1024
Swish Mul_153 1 1 273 275
Convolution Conv_154 1 1 275 276 0=32 1=3 4=1 5=1 6=9216
Swish Mul_156 1 1 276 278
Convolution Conv_157 1 1 269_splitncnn_0 279 0=32 1=1 5=1 6=4096
Swish Mul_159 1 1 279 281
Concat Concat_160 2 1 278 281 282
Convolution Conv_161 1 1 282 283 0=64 1=1 5=1 6=4096
Swish Mul_163 1 1 283 285
Split splitncnn_20 1 2 285 285_splitncnn_0 285_splitncnn_1
Convolution Conv_164 1 1 285_splitncnn_1 286 0=64 1=3 3=2 4=1 5=1 6=36864
Swish Mul_166 1 1 286 288
Concat Concat_167 2 1 288 263_splitncnn_0 289
Split splitncnn_21 1 2 289 289_splitncnn_0 289_splitncnn_1
Convolution Conv_168 1 1 289_splitncnn_1 290 0=64 1=1 5=1 6=8192
Swish Mul_170 1 1 290 292
Convolution Conv_171 1 1 292 293 0=64 1=1 5=1 6=4096
Swish Mul_173 1 1 293 295
Convolution Conv_174 1 1 295 296 0=64 1=3 4=1 5=1 6=36864
Swish Mul_176 1 1 296 298
Convolution Conv_177 1 1 289_splitncnn_0 299 0=64 1=1 5=1 6=8192
Swish Mul_179 1 1 299 301
Concat Concat_180 2 1 298 301 302
Convolution Conv_181 1 1 302 303 0=128 1=1 5=1 6=16384
Swish Mul_183 1 1 303 305
Split splitncnn_22 1 2 305 305_splitncnn_0 305_splitncnn_1
Convolution Conv_184 1 1 305_splitncnn_1 306 0=128 1=3 3=2 4=1 5=1 6=147456
Swish Mul_186 1 1 306 308
Concat Concat_187 2 1 308 238_splitncnn_0 309
Split splitncnn_23 1 2 309 309_splitncnn_0 309_splitncnn_1
Convolution Conv_188 1 1 309_splitncnn_1 310 0=128 1=1 5=1 6=32768
Swish Mul_190 1 1 310 312
Convolution Conv_191 1 1 312 313 0=128 1=1 5=1 6=16384
Swish Mul_193 1 1 313 315
Convolution Conv_194 1 1 315 316 0=128 1=3 4=1 5=1 6=147456
Swish Mul_196 1 1 316 318
Convolution Conv_197 1 1 309_splitncnn_0 319 0=128 1=1 5=1 6=32768
Swish Mul_199 1 1 319 321
Concat Concat_200 2 1 318 321 322
Convolution Conv_201 1 1 322 323 0=256 1=1 5=1 6=65536
Swish Mul_203 1 1 323 325
Convolution Conv_204 1 1 285_splitncnn_0 326 0=36 1=1 5=1 6=2304
Reshape Reshape_216 1 1 326 338 0=-1 1=12 2=3
Permute Transpose_217 1 1 338 output 0=1
Convolution Conv_218 1 1 305_splitncnn_0 340 0=36 1=1 5=1 6=4608
Reshape Reshape_230 1 1 340 352 0=-1 1=12 2=3
Permute Transpose_231 1 1 352 353 0=1
Convolution Conv_232 1 1 325 354 0=36 1=1 5=1 6=9216
Reshape Reshape_244 1 1 354 366 0=-1 1=12 2=3
Permute Transpose_245 1 1 366 367 0=1

k10s72fa

k10s72fa2#

现在强烈建议采用pnnx来转换pytorch模型,这里贴一下nihui新写的使用教程 https://zhuanlan.zhihu.com/p/471357671

相关问题