基于CPU使用paddlex OCR识别图片内容

一、安装 Miniconda(轻量版 Conda)​

paddlex CPU版本使用avx指令加速,需要确保系统和CPU支持avx指令(centos 7不支持)。

检查是否支持avx指令

bash 复制代码
dmesg | grep -i avx

查看 x86还是arm

bash 复制代码
uname -m

1. 下载 Miniconda 安装脚本

bash 复制代码
 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

2. 运行安装脚本

bash 复制代码
bash Miniconda3-latest-Linux-x86_64.sh
复制代码
Miniconda3 will now be installed into this location:
/home/super/miniconda3

[/home/super/miniconda3] >>> 
PREFIX=/home/super/miniconda3

3. 激活 Conda

bash 复制代码
 source ~/.bashrc  # 若使用 Bash

4. 验证安装

bash 复制代码
conda --version

二、使用 Conda 安装 Python 3.10.0

1. 创建独立环境(推荐)​

bash 复制代码
conda create -n PaddleImageOcr python=3.10.15

2. 激活环境

bash 复制代码
conda activate PaddleImageOcr

3. 验证 Python 版本

bash 复制代码
python --version

三、配置 Conda 镜像源(国内加速)​

1. 生成镜像配置文件

bash 复制代码
 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
    conda config --set show_channel_urls yes

2. 查看配置

bash 复制代码
conda config --show channels

四、安装 PaddlePaddle

临时切换国内源

bash 复制代码
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple

CPU 版本

bash 复制代码
  python -m pip install paddlepaddle==3.0.0rc0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/

GPU 版本,需显卡驱动程序版本 ≥450.80.02(Linux)或 ≥452.39(Windows)

bash 复制代码
  python -m pip install paddlepaddle-gpu==3.0.0rc0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/

GPU 版本,需显卡驱动程序版本 ≥545.23.06(Linux)或 ≥545.84(Windows)

bash 复制代码
  python -m pip install paddlepaddle-gpu==3.0.0rc0 -i https://www.paddlepaddle.org.cn/packages/stable/cu123/

五、安装PaddleX

bash 复制代码
  pip install https://paddle-model-ecology.bj.bcebos.com/paddlex/whl/paddlex-3.0.0rc0-py3-none-any.whl

六、执行图片OCR

bash 复制代码
  paddlex --pipeline OCR --input ./20250306-152918.jpg --device cpu
  paddlex --pipeline OCR --input D:/temp/tess4j/20250306-152918.jpg --device cpu

输出结果

耗时10s,准确率较高,图片分辨率不高也能识别。

七、安装Paddle Serving服务端​(需Python环境):

安装服务化部署插件

bash 复制代码
  paddlex --install serving

启动服务

bash 复制代码
nohup paddlex --serve --port 8080 --pipeline OCR --device cpu --save_path /tmp/PaddleImageOcr > paddleImageOcr.log 2>&1 &

http请求

bash 复制代码
curl --location '127.0.0.1:8080/ocr' \
--header 'Content-Type: application/json' \
--data '{
   "file":"https://oss.xxx.com/image/xxx.jpg"
}'

问题

ERROR: Could not find a version that satisfies the requirement Pillow (from paddlepaddle) (from versions: none)

设定安装源、信任安装源、PIL已被Pillow替代

bash 复制代码
 pip install Pillow -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
相关推荐
大邳草民32 分钟前
深入理解 Python 的属性化方法
开发语言·笔记·python
洗紫2 小时前
Python中的条件语句怎么使用?
python
南汐汐月2 小时前
重生归来,我要成功 Python 高手--day35 深度学习 Pytorch
pytorch·python·深度学习
java1234_小锋2 小时前
[免费]基于Python的深度学习豆瓣电影数据可视化+情感分析推荐系统(Flask+Vue+LSTM+scrapy)【论文+源码+SQL脚本】
python·信息可视化·flask·电影数据可视化
paopao_wu2 小时前
DeepSeek-OCR实战(05):DeepSeek-OCR-WebUI部署(Docker)
docker·ai·容器·ocr
PieroPc3 小时前
一个基于Python Streamlit sqlite3 的销售单管理系统,提供商品管理、客户管理、销售单管理及打印,和应收对账单等功能
python·oracle·sqlite·streamlit
月下倩影时3 小时前
视觉进阶篇—— PyTorch 安装
人工智能·pytorch·python
OpenBayes3 小时前
教程上新丨Deepseek-OCR 以极少视觉 token 数在端到端模型中实现 SOTA
人工智能·深度学习·机器学习·ocr·大语言模型·文本处理·deepseek
kevin 13 小时前
财报OCR录入识别软件准确率高吗?易道博识财报录入实测效果如何?
ocr
❀͜͡傀儡师3 小时前
Docker 部署 DeepSeek-OCR 和WebUI
docker·容器·ocr