• OpenVINO 2023.0 实战七:OpenVINO部署PaddleOCR v4模型


    1 将paddle-ocr模型权重转换为ov格式

    PP-OCRv4_det_infer

    paddle2onnx --model_dir /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_det_infer --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_det_infer/det.onnx --opset_version 12 --input_shape_dict="{'x':[-1,3,-1,960]}" --enable_onnx_checker True
    mo --input_model /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_det_infer/det.onnx --output_dir /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_det_infer
    
    • 1
    • 2

    ppocr_mobile_v2.0_cls_infer

    paddle2onnx --model_dir /home/share_data/tmp/ch_PP-OCRv4/ch_ppocr_mobile_v2.0_cls_infer --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file /home/share_data/tmp/ch_PP-OCRv4/ch_ppocr_mobile_v2.0_cls_infer/cls.onnx --opset_version 12 --input_shape_dict="{'x':[-1,3,48,192]}" --enable_onnx_checker True
    mo --input_model /home/share_data/tmp/ch_PP-OCRv4/ch_ppocr_mobile_v2.0_cls_infer/cls.onnx --output_dir /home/share_data/tmp/ch_PP-OCRv4/ch_ppocr_mobile_v2.0_cls_infer
    
    • 1
    • 2

    PP-OCRv4_rec_infer

    paddle2onnx --model_dir /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_rec_infer --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_rec_infer/rec.onnx --opset_version 12 --input_shape_dict="{'x':[-1,3,48,-1]}" --enable_onnx_checker True
    mo --input_model /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_rec_infer/rec.onnx --output_dir /home/share_data/tmp/ch_PP-OCRv4/ch_PP-OCRv4_rec_infer
    
    • 1
    • 2

    2 在 Visual Studio 中配置项目属性

    Release:
    属性 --> VC++ 目录 --> 包含目录

    C:\Intel\openvino_2023.0.0\runtime\include
    E:\opencv470\build\include
    E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\gflags\include
    
    • 1
    • 2
    • 3

    属性 --> VC++ 目录 --> 库目录

    E:\opencv470\build\x64\vc16\lib
    C:\Intel\openvino_2023.0.0\runtime\lib\intel64\Release
    E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\gflags\lib
    
    • 1
    • 2
    • 3

    属性 --> 链接器 --> 输入 --> 附加依赖项

    opencv_world470.lib
    openvino.lib
    openvino_onnx_frontend.lib
    openvino_paddle_frontend.lib
    openvino_pytorch_frontend.lib
    gflags_static.lib
    shlwapi.lib
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    动态链接库 配置
    将 C:\Intel\openvino_2023.0.0\runtime\bin\intel64\Release目录下的

    openvino.dll
    openvino_intel_cpu_plugin.dll
    openvino_ir_frontend.dll
    
    • 1
    • 2
    • 3

    将 E:\opencv470\mybuild\x64\vc15\bin 目录下的

    opencv_world470.dll
    
    • 1

    移动到 可执行文件目录。

    3 遇到的问题

    1. error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”
      1>gflags_static.lib(gflags.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>gflags_static.lib(gflags_reporting.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>gflags_static.lib(gflags_completions.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>libcpmt.lib(locale0.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>libcpmt.lib(cerr.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>libcpmt.lib(locale.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>libcpmt.lib(iosptrs.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      1>libcpmt.lib(ios.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu_ov.obj 中)
      解决方法:在工程上右键->属性->c/c+±>代码生成->运行库 选择 /MT
      在这里插入图片描述

    2. error LNK2001: 无法解析的外部符号 __imp_PathMatchSpecA
      gflags_static.lib(gflags.cc.obj) : error LNK2001: 无法解析的外部符号 __imp_PathMatchSpecA
      解决方法:项目属性 -》链接器-》输入-》附加依赖项-》加上shlwapi.lib

  • 相关阅读:
    Linux基本命令,基础知识
    nginx中deny和allow详解
    17--Django-项目实战-博客开发-登录功能和首页页面搭建
    一键智能视频语音转文本——基于PaddlePaddle语音识别与Python轻松提取视频语音并生成文案
    docker-compose安装mysql主流版本及差异
    Vinco Ventures任命Ted Farnsworth为联合首席执行官
    AI辅助研发正在成为造福人类的新生科技力量
    Python 5个极易混淆的核心概念
    GIT简单使用
    webpack构建vue项目 基础09之生产环境 打包为zip文件 与 public静态文件的copy
  • 原文地址:https://blog.csdn.net/shanglianlm/article/details/134070703