安装paddleocr
按照前篇搭建tensorflow的方式,使用mx450显卡,下载cuda工具包11.0和cudnn库8.0.4,当前时间节点conda没有cuda11的工具包,只能使用安装软件的方式安装cuda
,然后把cudnn解压后的文件放置cuda安装目录对应的位置,
使用anaconda创建环境,python版本按照官方要求就行了,这里是用的3.7
创建一个paddlepaddle的环境,
conda create -n paddle2 python=3.7
切换进这个环境
conda activate paddle2
1 安装paddlepaddle,这里因为有gpu就选择gpu的方式,如果无gpu,就选cpu版本就好了
使用官方给的方式安装,
python -m pip install paddlepaddle-gpu==2.0.0rc1.post110 -f https://paddlepaddle.org.cn/whl/stable.html(因为在conda环境下了,把python -m省略)
验证安装
(paddle2) C:\Users\yu>python
Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> paddle.utils.run_check()
Running verify PaddlePaddle program ...
W0121 21:46:24.748905 10948 device_context.cc:320] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 11.0, Runtime API Version: 11.0
W0121 21:46:25.631645 10948 device_context.cc:330] device: 0, cuDNN Version: 8.0.
PaddlePaddle works well on 1 GPU.
W0121 21:46:33.943255 10948 build_strategy.cc:171] fusion_group is not enabled for Windows/MacOS now, and only effective when running with CUDA GPU.
PaddlePaddle works well on 1 GPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
出现最下面一行提示安装成功.
2 下载paddleocr
2.1 首先在电脑上找个位置新建个文件夹,自己取名字
然后使用git拉取paddleocr项目到这个文件夹,按照paddleocr在github上给的方式
git clone https://github.com/PaddlePaddle/PaddleOCR
如果掉线,就使用码云上的项目或者手动下载项目解压到文件夹,使用码云拉取项目方式如下
git clone https://gitee.com/paddlepaddle/PaddleOCR
2.2进入下载的项目中
cd PaddleOCR
该项目中有项目依赖的第三方包,在PaddleOCR目录中的requirements.txt中,使用下面命令安装python3 -m pip install -r requirements.txt (这里使用的是conda下的环境,不能使用python3 -m ,直接pip安装就可以了)
pip install -r filename命令是安装文件filename中的包,这里使用的是相对路径
安装过程中,没有vs环境可能会有包安装不上去,会报红,把安装不上去的包去www.lfd.uci.edu离线下载下来,
然后使用pip安装wheel文件的方式安装,cd到wheel文件目录,pip install xxx.wheel
到这里基本上就下载好了
2.3去官方github项目地址中下载 模型,进行验证paddleocr能否使用
以中英文超轻量模型为例,将检测模型/方向分类器/识别模型的推理模型压缩包分别下载下来
在PaddleOCR项目目录下,新建文件夹,命名inference,将三个压缩包分别加压,放入inference文件夹下,如图
如此就算基本配置完毕了,可以试用该项目提供的模型看下识别效果了
2.4按照官方的预测命令,识别单个图片文字如下
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v1.1_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v1.1_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v1.1_cls_infer/" --use_angle_cls=True --use_space_char=True
在conda的paddle2环境下,要把python3改为python
2.5 在win10下,可能会报有些模块找不到的问题,那就pip安装这些模块,如果报Winerror 126的错误,是因为Shapely包不正确,就需要先卸载pip uninstall Shapely,再去www.lfd.uci.edu离线下载这个包,然后手动安装这个离线包
然后再运行上面的预测命令,能正常输出图片上的文字,就说明这个项目的环境已经配置好了.