paddleocr转onnx模型推理
PaddleOCR
Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
项目地址:https://gitcode.com/gh_mirrors/pa/PaddleOCR
免费下载资源
·
环境
paddle2onnx=1.2.6 paddlepaddle-gpu=2.6.1
paddle2onnx
paddle2onnx --model_dir inference/dtiaoma/db_mv3_lr0.0001 --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file ./onnx_model/det_large.onnx --opset_version 11 --enable_onnx_checker True
- 这里是动态输入,后续转为固定尺寸待补充
推理
参考:这里
onnx优化
让onnx模型更加精简
import onnx
import onnxsim #import simplify
model = onnx.load("onnx_model/det_large.onnx")
model_sim,flag = onnxsim.simplify(model)
if not flag:
print("failed")
onnx.save(model_sim,"onnx_model/det_large_sim.onnx")
可以参考:onnx精简
但是实际测试发现区别不大,大家可以验证自己模型前后效果。
分析模型计算量、内存等
import onnx_tool
modelpath = 'onnx_model/det_large_sim.onnx'
onnx_tool.model_profile(modelpath,dynamic_shapes={'x':np.zeros((1,3,224,224))})
问题1:‘type’ object is not subscriptable 更新onnx_tool版本到>=0.2.1
问题2:Input x’s shape is dynamic, please set it a fixed input dimension 添加固定形状dynamic_shapes={‘x’:np.zeros((1,3,640,640))}
GitHub 加速计划 / pa / PaddleOCR
44
11
下载
Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
最近提交(Master分支:4 个月前 )
0697d248
2 天前
04c989b7
5 天前
更多推荐
已为社区贡献2条内容
所有评论(0)