飞桨(https://www.paddlepaddle.org.cn)是一个非常实用方便的机器学习库,今天实验了一下ocr功能。
记录一下安装过程:
安装python3:
yum -y install python3
python -V
修改python的软链接为python3:
rm -rf /usr/bin/python
rm -rf /usr/bin/pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
安装完python3会导致防火墙firewalld和yum运行报错,只需要手工修改脚本中第一行的python为python2即可:
vim /usr/sbin/firewalld
修改 /usr/bin/python 为 /usr/bin/python2
vim /usr/bin/firewall-cmd
同上
vim /usr/bin/yum
同上
安装基础环境:
yum install gcc g++ make cmake automake zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make mysql-devel gcc-devel python-devel -y
安装Anaconda3(安装目录为:/usr/local/etc/anaconda3):
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
chmod +x Anaconda3-2020.11-Linux-x86_64.sh
./Anaconda3-2020.11-Linux-x86_64.sh
修复CXXABI版本过低的问题:
yum install -y bzip2
cp /usr/local/etc/anaconda3/lib/libstdc++.so.6.0.26 /usr/lib64
strings /usr/lib64/libstdc++.so.6.0.26 |grep 'CXXABI'
cd /usr/lib64
rm -rf libstdc++.so.6
ln -s libstdc++.so.6.0.26 libstdc++.so.6
strings /usr/lib64/libstdc++.so.6 | grep 'CXXABI'
安装python的模块:
python -m pip install --upgrade pip
pip install shapely pyclipper dataclass pyclipper
yum install libffi-devel wget libxml2-devel libxslt-devel -y
pip install lxml requests
安装飞桨:
pip install hub
pip install paddlepaddle -U
pip install paddlehub
如果提示“spyder 4.1.5 requires pyqt5<5.13”,使用下面两条命令安装:
pip install --user pyqt5==5.12.0
pip install --user pyqtwebengine==5.12.0
安装ocr:
hub install chinese_ocr_db_crnn_mobile==1.1.1
hub install chinese_ocr_db_crnn_server==1.1.1
测试ocr:
hub run chinese_ocr_db_crnn_server --input_path "/root/test.jpg" --output_dir /root/output_ocr --visualization 1
测试分词:
hub run lac --input_text "在世界上,有五百多万中动物。"