Open lmq5294249 opened 1 year ago
同问
本辣鸡根据你给的链接,看到了它提供了推理的代码,其中需要的预处理是BGR->RGB,mean_vals=0.f norm_vals=1.f 具体链接可以看infer 至于问题2,怎么获取输入输出层名称,你可以用netron打开你转换出来的param文件,然后就能看到输入和输出blob的名称了
本辣鸡根据你给的链接,看到了它提供了推理的代码,其中需要的预处理是BGR->RGB,mean_vals=0.f norm_vals=1.f 具体链接可以看infer 至于问题2,怎么获取输入输出层名称,你可以用netron打开你转换出来的param文件,然后就能看到输入和输出blob的名称了
谢谢,我用你提供的参数谢了代码测试。 我用netron打开param文件是可可以找到输入和输出blob的名称,但是我不确定我是否选错输出的blob,最后一层是输出485,但是测试输出貌似数据结构不对。麻烦帮我看一下输出是哪一个?谢谢
最后的输出层确实是485,但是可能是pooling层后面出了点问题。建议使用torch->torchscript->pnnx->ncnn,onnx2ncnn有时候总会存在些问题。
针对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
我通过将模型pth转为onnx在转为ncnn模型,但是不知道怎么获取mean_vals,norm_vals参数 原项目地址:https://github.com/JDAI-CV/fast-reid/tree/6300bd756e341ca180c60b8e07c218b9eb40664a/tools/deploy Use official fast-reid to transform PyTorch weights to ONNX model. Run the following command python onnx_export.py --config-file root-path/bagtricks_R50/config.yml --name baseline_R50 --output outputs/onnx_model --opts MODEL.WEIGHTS root-path/logs/market1501/bagtricks_R50/model_final.pth
可以得到onnx模型: fast-reid_mobilenetv2.onnx.zip
转换后的ncnn model为: fast-reid_mobilenetv2-sim-opt.zip
但是,这样如何获取到mean_vals,norm_vals参数,还有输入输出的层名称