ubuntu

PaddleOCR在Ubuntu上的运行环境配置

小樊
83
2024-09-12 07:05:22
栏目: 智能运维

在 Ubuntu 上配置 PaddleOCR 的运行环境,需要以下几个步骤:

  1. 安装 Python 和 pip:

    PaddleOCR 需要 Python 3.6+ 版本。使用以下命令安装 Python 和 pip:

    sudo apt-get update
    sudo apt-get install python3
    sudo apt-get install python3-pip
    
  2. 安装 PaddlePaddle:

    PaddleOCR 需要 PaddlePaddle 2.0+ 版本。使用以下命令安装 PaddlePaddle:

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

    如果需要 GPU 版本的 PaddlePaddle,可以使用以下命令:

    python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
    
  3. 克隆 PaddleOCR 仓库:

    git clone https://github.com/PaddlePaddle/PaddleOCR.git
    cd PaddleOCR
    
  4. 安装 PaddleOCR 依赖:

    python3 -m pip install -r requirements.txt -i https://mirror.baidu.com/pypi/simple
    
  5. 下载 PaddleOCR 模型:

    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_server_v2.0_rec_infer.tar
    wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/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
    tar xf ch_ppocr_mobile_v2.0_cls_infer.tar
    
    mv ch_ppocr_server_v2.0_det_infer det_model
    mv ch_ppocr_server_v2.0_rec_infer rec_model
    mv ch_ppocr_mobile_v2.0_cls_infer cls_model
    
  6. 测试 PaddleOCR:

    python3 tools/infer/predict_system.py --image_dir=./doc/imgs/11.jpg --det_model_dir=./det_model --rec_model_dir=./rec_model --cls_model_dir=./cls_model --use_gpu=False --use_space_char=True
    

    如果需要使用 GPU,将 --use_gpu 参数设置为 True

现在,你已经成功配置了 PaddleOCR 的运行环境。你可以使用 PaddleOCR 进行文本识别和其他任务。更多关于 PaddleOCR 的信息和使用方法,请参考官方文档:https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.3/README_ch.md

0
看了该问题的人还看了