biubug6 / Face-Detector-1MB-with-landmark

1M人脸检测模型(含关键点)
MIT License
1.02k stars 271 forks source link

关于转onnx和ncnn的param参数输出不同的问题 #45

Closed ylc2580 closed 3 years ago

ylc2580 commented 3 years ago

你好,首先非常感谢咱们的project。使用过程中发现几个问题。 使用咱们提供的转onxx代码转换mobile0.25的模型并simple后,输层名称分别是,586,output0和585,使用netron查看后可看见: (1)output0是1 4200 4的输出; (2)586是1 4200 2的输出; (3)585是1 4200 10的输出; 然后将其按照咱们过程转为ncnn模型,然后: std::cout<<"output0 shape = "<<out.c <<" "<<out.w <<" "<<out.h <<" "<<out.elemsize<<std::endl; std::cout<<"586 shape = "<<out1.c<<" "<<out1.w<<" "<<out1.h<<" "<<out1.elemsize<<std::endl; std::cout<<"585 shape = "<<out2.c<<" "<<out2.w<<" "<<out2.h<<" "<<out2.elemsize<<std::endl; 打印后,输出分别为: output0 shape = 1 4 3160 4 586 shape = 1 2 3160 4 585 shape = 1 10 3160 4

slim模型也有同样的问题,onnx的是5875 4(或者2或者10),但param的是4200 4(或者2或者10)。

问题是:为什么咱们这里的onnx模型和param模型输出的向量长度不一样呢?

ylc2580 commented 3 years ago

问题已解决。

转onnx的代码中默认模型的输入为320*320的,但实际的ncnn代码中resize后的图像的最大边是320,另一个一般是小于320的,这就导致了ncnn的比onnx的输出向量小一些。只需要将ncnn代码中的reszie模块固定为320,并修改后面模型输出对应原图的相应的scale即可。