ncnn
ncnn copied to clipboard
Cannot convert ch_PP-OCRv4_rec
paddle2onnx : 1.0.6 onnxsim : 0.4.35 ncnn : 20230816
Steps:
- Convert paddle model to onnx by paddle2onnx
paddle2onnx --model_dir ./ch/ch_PP-OCRv4_rec_infer ^ --model_filename inference.pdmodel ^ --params_filename inference.pdiparams ^ --save_file ./ch/rec_onnx/model.onnx ^ --opset_version 11 ^ --input_shape_dict="{'x':[-1,3,-1,-1]}" ^ --enable_onnx_checker True
- Simplify model.onnx by onnxsim
python -m onnxsim model.onnx out_simple.onnx
The output still exist layers
Reshape | 6 | 6
Shape | 4 | 3
- Convert out_simple.onnx to ncnn model
onnx2ncnn.exe ch_PP-OCRv4_rec_simple.onnx out.param out.bin
Error messages:
Shape not supported yet! Unknown data type 0 Shape not supported yet! Cast not supported yet!
to=6
Cast not supported yet!
to=7
Unknown data type 0 Unsupported transpose type ! Unsupported squeeze axes ! Unsupported squeeze axes ! Unsupported squeeze axes ! Unknown data type 0 Shape not supported yet! Cast not supported yet!
to=6
Cast not supported yet!
to=7
Unknown data type 0 Unsupported transpose type ! Unsupported squeeze axes ! Unsupported squeeze axes ! Unsupported squeeze axes ! Unknown data type 0
Model Model link, link of the document.
Did you find any solution to this problem? I tried to convert PP-OCRv3 recognition models, same problem. The detection models can be converted without any problems. Please help.
Did you find any solution to this problem? I tried to convert PP-OCRv3 recognition models, same problem. The detection models can be converted without any problems. Please help.
No, I guess this one is not an easy task, may need to create custom layer. PP-OCRv3 looks fine with me, you could download them from this site too--https://github.com/FeiGeChuanShu/ncnn_paddleocr
针对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