PaddleOCR 安装与简单使用(windows)

文章转载自: https://blog.csdn.net/f2315895270/article/details/128147744

前提 

      已经安装好Python环境

     PaddleOCR官方主页:https://www.paddlepaddle.org.cn/
     GitHub地址:https://github.com/PaddlePaddle/PaddleOCR
     Gitee地址:https://gitee.com/paddlepaddle/PaddleOCR

安装PaddleOCR

     我下面所有的命令安装后面都跟了-i https://mirror.baidu.com/pypi/simple 这是指定他的源是百度那边,如果不加这个会很慢,所以建议后面的安装都加上相关指定

安装Paddle

    根据自己机器选择GPU还是CPU的版本,GPU还分了10和9,可自行查看
    这里是CPU版本,所以安装的是CPU版本

pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

   安装好之后可以在python的依赖包目录里面查看是否安装成功,windows的路径一般都在你的python安装路径\Lib\site-packages里面

   

安装PaddleOCR包

    这里网上有两种安装方式,一种是官方推荐的直接全局安装PaddleOCR,这样后面就可以直接在任意位置进行命令调取,还有一种是安装解压包然后进行使用,我两者都有使用

全局安装

    pip install paddleocr -i https://mirror.baidu.com/pypi/simple

   这里的安装很有可能会报错,一般都是缺少模块的问题,看报的错误缺少什么模块就用pip把相关模块安装好之后再安装就行了
   如果还是报错可以手动下载相关模块的shapely安装包完成安装,地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

   还是老样子,安装好之后可以在python的依赖包目录下面查看

       

 

解压包安装

    在github或者gitee上面可以下载相关的解压包,下载地址: https://github.com/PaddlePaddle/PaddleOCR

    

 

 然后在当前路径下通过命令进行相关模块的安装  

     pip install -r requirements.txt -i https://mirror.baidu.com/pypi/simple

中途可能会报错

      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for lanms-neo
      Failed to build lanms-neo
      ERROR: Could not build wheels for lanms-neo, which is required to install pyproject.toml-based projects
这里我查阅了很多资料,有说指定paddleocr版本为2.0.6的,有说缺少c++环境的,经过我自己的测试,发现应该是缺少c++环境导致,然后网上一些说缺少这个版本,一些说缺少那个版本,实在看的我眼花,最后索性直接通过Visual Studio installer工具进行相关项的安装

 

 

 

 我是安装了这几个组件,安装好之后最好重启一下电脑
然后再次通过命令安装相关的依赖模块就不报错了,成功安装好需要的包

运行

    把图片放到指定的路径,然后运行命令

       paddleocr --image_dir ./imgs/11.jpg --use_angle_cls true --use_gpu false

   运行命令可能报错:

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

    解决方案:   

        删除 Anaconda3目录下的  ./Library/bin/libiomp5md.dll 文件即可

        参考博客: https://blog.csdn.net/weixin_43823786/article/details/124525625

     最后控制台输出结果:

      

模型下载

    

      paddleocr提供了很多推理模型供我们下载,想要对于不同场景进行识别,需要下载相应的模型
     下载地址:https://gitee.com/paddlepaddle/PaddleOCR/blob/release/2.6/doc/doc_ch/models_list.md
     下载好之后在paddlerocr的目录下面新建inference文件夹,然后把模型解压后的包放进去,启动的时候可以通过参数指定模型即可

 

    

posted @ 2023-04-03 15:39  fy_qxl  阅读(2118)  评论(0编辑  收藏  举报