• Centos7部署PaddleOCR环境


    一、安装python3.7

    
    

    1、下载源码包

    # 切换到root目录
    [root@localhost ~] cd /root/
    
    # 安装wget
    [root@localhost ~] yum -y install wget
    
    # 使用wget下载到目录
    [root@localhost ~] wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
    
    # 解压
    [root@localhost ~] tar xvf Python-3.7.0.tar.xz

    2、安装依赖

    [root@localhost ~] yum install gcc openssl-devel bzip2-devel expat-devel gdbm-devel sqlite-devel libffi-devel

    3、编译安装

    # 切换到解压后的目录Python-3.7.0

    [root@localhost ~] cd Python-3.7.0

    # 编译

    [root@localhost Python-3.7.0] ./configure --prefix=/usr/local/python3.7 --enable-shared CFLAGS=-fPIC

    # 生成安装文件,进行安装

    [root@localhost Python-3.7.0] make && make install

    4、配置环境

    # 备份python软连接,pip如果不存在就不用备份

    [root@localhost Python-3.7.0] mv -i /usr/bin/python /usr/bin/python.bak

    [root@localhost Python-3.7.0] mv -i /usr/bin/pip /usr/bin/pip.bak

    # 创建python3的连接

    [root@localhost Python-3.7.0] ln -sv /usr/local/python3.7/bin/python3 /usr/bin/python

    [root@localhost Python-3.7.0] ln -sv /usr/local/python3.7/bin/pip3 /usr/bin/pip

    # 配置动态库

    [root@localhost Python-3.7.0]

    vim /etc/ld.so.conf.d/python.conf

    # 写入内容

    /usr/local/python3.7/lib

    # 跳转到/usr/local/python3.7/bin

    [root@localhost Python-3.7.0] cd /usr/local/python3.7/bin

    # 启用配置

    [root@localhost Python-3.7.0] ldconfig

     二、下载代码

    # 1、创建并切换切换到工作目录下
    cd /home/Projects
    
    # 2. 安装PaddlePaddle 2.0
    pip3 install --upgrade pip
    
    如果您的机器安装的是CUDA9或CUDA10,请运行以下命令安装
    python3 -m pip install paddlepaddle-gpu==2.0.0 -i https://mirror.baidu.com/pypi/simple
    
    如果您的机器是CPU,请运行以下命令安装
    
    python3 -m pip install paddlepaddle==2.0.0 -i https://mirror.baidu.com/pypi/simple
    
    更多的版本需求,请参照[安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。

    # 3、下载源码
    【推荐】git clone https://github.com/PaddlePaddle/PaddleOCR
    
    如果因为网络问题无法pull成功,也可选择使用码云上的托管:
    
    git clone https://gitee.com/paddlepaddle/PaddleOCR
    
    注:码云托管代码可能无法实时同步本github项目更新,存在3~5天延时,请优先使用推荐方式。


    #4、安装第三方库

      cd PaddleOCR
      pip3 install -r requirements.txt

    #5、下载模型
    下载检测模型  wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar
    下载方向分类器 wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar
    下载识别模型 wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar
    解压压缩包
    tar xf ch_ppocr_mobile_v2.0_cls_infer.tar
    tar xf ch_ppocr_server_v2.0_det_infer.tar 
    tar xf ch_ppocr_server_v2.0_rec_infer.tar

     三、运行代码

    python tools/infer/predict_system.py 
    --image_dir="/home/Projects/img/1.png" #设置需要识别的图片
    #设置模型
    --det_model_dir="./inference/ch_ppocr_server_v2.0_det_infer/"
    --rec_model_dir="./inference/ch_ppocr_server_v2.0_rec_infer/"
    --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/"
    --use_angle_cls=True --use_space_char=True --use_gpu=False

    四、遇到的问题

    1、ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)

    提示缺少库,GLIBC_2.18 缺失,执行下列方法,途中不要退出,即可解决

    curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
    tar zxf glibc-2.18.tar.gz 
    cd glibc-2.18/
    mkdir build
    cd build/
    ../configure --prefix=/usr
    make -j2
    make install
    # 查看版本
    strings /usr/lib64/libstdc++.so.6 |grep GLIBC

     2、ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found

    参考链接
    https://blog.csdn.net/qq_42078965/article/details/104360201
    
    https://blog.csdn.net/zerow__/article/details/88845192
  • 相关阅读:
    华为花了100亿,为员工造了12个欧洲小镇,幸福到爆棚
    Qt5.9 官方发布的新版本亮点的确不胜枚举(而且修复2000+ bugs)
    详尽分析世纪之战:360VS腾讯是两个阶层的抗争
    c#
    PhantomJS
    bootstrap table
    Linux 入门
    多路搜索树
    网站性能优化工具
    NetCore上传多文件
  • 原文地址:https://www.cnblogs.com/raorao1994/p/15055499.html
Copyright © 2020-2023  润新知