Upgrade document structure
This commit is contained in:
parent
960f7fcec3
commit
fd62f27877
40
README.md
40
README.md
|
@ -78,25 +78,29 @@ For more model downloads (including multiple languages), please refer to [PP-OCR
|
|||
For a new language request, please refer to [Guideline for new language_requests](#language_requests).
|
||||
|
||||
## Tutorials
|
||||
- [Installation](./doc/doc_en/installation_en.md)
|
||||
- [Quick Start](./doc/doc_en/quickstart_en.md)
|
||||
- [Code Structure](./doc/doc_en/tree_en.md)
|
||||
- Algorithm Introduction
|
||||
- [Text Detection Algorithm](./doc/doc_en/algorithm_overview_en.md)
|
||||
- [Text Recognition Algorithm](./doc/doc_en/algorithm_overview_en.md)
|
||||
- [PP-OCR Pipeline](#PP-OCR-Pipeline)
|
||||
- Model Training/Evaluation
|
||||
- [Text Detection](./doc/doc_en/detection_en.md)
|
||||
- [Text Recognition](./doc/doc_en/recognition_en.md)
|
||||
- [Direction Classification](./doc/doc_en/angle_class_en.md)
|
||||
- [Yml Configuration](./doc/doc_en/config_en.md)
|
||||
- Inference and Deployment
|
||||
- [Quick Inference Based on PIP](./doc/doc_en/whl_en.md)
|
||||
- [Python Inference](./doc/doc_en/inference_en.md)
|
||||
- [C++ Inference](./deploy/cpp_infer/readme_en.md)
|
||||
- [Serving](./deploy/pdserving/README.md)
|
||||
- [Mobile](./deploy/lite/readme_en.md)
|
||||
- [Benchmark](./doc/doc_en/benchmark_en.md)
|
||||
- [PaddleOCR Overview and Installation](./doc/doc_en/paddleOCR_overview.md)
|
||||
- PP-OCR Industry Landing: from Training to Deployment
|
||||
- [PP-OCR Model and Configuration](./doc/doc_en/models_and_config_en.md)
|
||||
- [PP-OCR Model Download](./doc/doc_en/models_list_en.md)
|
||||
- [Yml Configuration](./doc/doc_en/config_en.md)
|
||||
- [Python Inference](./doc/doc_en/inference_en.md)
|
||||
- [PP-OCR Training](./doc/doc_en/training.md)
|
||||
- [Text Detection](./doc/doc_en/detection_en.md)
|
||||
- [Text Recognition](./doc/doc_en/recognition_en.md)
|
||||
- [Direction Classification](./doc/doc_en/angle_class_en.md)
|
||||
- Inference and Deployment
|
||||
- [Python Inference](./doc/doc_en/inference_en.md)
|
||||
- [C++ Inference](./deploy/cpp_infer/readme_en.md)
|
||||
- [Serving](./deploy/pdserving/README.md)
|
||||
- [Mobile](./deploy/lite/readme_en.md)
|
||||
- [Benchmark](./doc/doc_en/benchmark_en.md)
|
||||
- [PP-Structure: Information Extraction](./ppstructure/README.md)
|
||||
- [Layout Parser](./ppstructure/layout/README.md)
|
||||
- [Table Recognition](./ppstructure/table/README.md)
|
||||
- Academic Circles
|
||||
- [Two-stage Algorithm](./doc/doc_en/algorithm_overview_en.md)
|
||||
- [PGNet Algorithm](./doc/doc_en/algorithm_overview_en.md)
|
||||
- Data Annotation and Synthesis
|
||||
- [Semi-automatic Annotation Tool: PPOCRLabel](./PPOCRLabel/README.md)
|
||||
- [Data Synthesis Tool: Style-Text](./StyleText/README.md)
|
||||
|
|
54
README_ch.md
54
README_ch.md
|
@ -72,36 +72,39 @@ PaddleOCR同时支持动态图与静态图两种编程范式
|
|||
更多模型下载(包括多语言),可以参考[PP-OCR v2.0 系列模型下载](./doc/doc_ch/models_list.md)
|
||||
|
||||
## 文档教程
|
||||
- [快速安装](./doc/doc_ch/installation.md)
|
||||
- [中文OCR模型快速使用](./doc/doc_ch/quickstart.md)
|
||||
- [多语言OCR模型快速使用](./doc/doc_ch/multi_languages.md)
|
||||
- [代码组织结构](./doc/doc_ch/tree.md)
|
||||
- 算法介绍
|
||||
- [文本检测](./doc/doc_ch/algorithm_overview.md)
|
||||
- [文本识别](./doc/doc_ch/algorithm_overview.md)
|
||||
- [PP-OCR Pipeline](#PP-OCR)
|
||||
- [端到端PGNet算法](./doc/doc_ch/pgnet.md)
|
||||
- 模型训练/评估
|
||||
- [文本检测](./doc/doc_ch/detection.md)
|
||||
- [文本识别](./doc/doc_ch/recognition.md)
|
||||
- [方向分类器](./doc/doc_ch/angle_class.md)
|
||||
- [yml参数配置文件介绍](./doc/doc_ch/config.md)
|
||||
- 预测部署
|
||||
- [基于pip安装whl包快速推理](./doc/doc_ch/whl.md)
|
||||
- [基于Python脚本预测引擎推理](./doc/doc_ch/inference.md)
|
||||
- [基于C++预测引擎推理](./deploy/cpp_infer/readme.md)
|
||||
- [服务化部署](./deploy/pdserving/README_CN.md)
|
||||
- [端侧部署](./deploy/lite/readme.md)
|
||||
- [Benchmark](./doc/doc_ch/benchmark.md)
|
||||
- 数据集
|
||||
- [通用中英文OCR数据集](./doc/doc_ch/datasets.md)
|
||||
- [手写中文OCR数据集](./doc/doc_ch/handwritten_datasets.md)
|
||||
- [垂类多语言OCR数据集](./doc/doc_ch/vertical_and_multilingual_datasets.md)
|
||||
- [快速开始](./doc/doc_ch/quickstart.md)
|
||||
- [PaddleOCR全景图与安装](./doc/doc_ch/paddleOCR_overview.md)
|
||||
- PP-OCR产业落地:从训练到部署
|
||||
- [PP-OCR模型与配置文件](./doc/doc_ch/models_and_config.md)
|
||||
- [PP-OCR模型下载](./doc/doc_ch/models_list.md)
|
||||
- [配置文件内容与生成](./doc/doc_ch/config.md)
|
||||
- [模型库快速使用](./doc/doc_ch/inference.md)
|
||||
- [PP-OCR模型训练](./doc/doc_ch/training.md)
|
||||
- [文本检测](./doc/doc_ch/detection.md)
|
||||
- [文本识别](./doc/doc_ch/recognition.md)
|
||||
- [方向分类器](./doc/doc_ch/angle_class.md)
|
||||
- PP-OCR模型推理部署
|
||||
- [基于Python脚本预测引擎推理](./doc/doc_ch/inference.md)
|
||||
- [基于C++预测引擎推理](./deploy/cpp_infer/readme.md)
|
||||
- [服务化部署](./deploy/pdserving/README_CN.md)
|
||||
- [端侧部署](./deploy/lite/readme.md)
|
||||
- [Benchmark](./doc/doc_ch/benchmark.md)
|
||||
- [PP-Structure信息提取](./ppstructure/README_ch.md)
|
||||
- [版面分析](./ppstructure/layout/README_ch.md)
|
||||
- [表格识别](./ppstructure/table/README_ch.md)
|
||||
- 数据标注与合成
|
||||
- [半自动标注工具PPOCRLabel](./PPOCRLabel/README_ch.md)
|
||||
- [数据合成工具Style-Text](./StyleText/README_ch.md)
|
||||
- [其它数据标注工具](./doc/doc_ch/data_annotation.md)
|
||||
- [其它数据合成工具](./doc/doc_ch/data_synthesis.md)
|
||||
- OCR学术圈
|
||||
- [两阶段模型介绍与下载](./doc/doc_ch/algorithm_overview.md)
|
||||
- [端到端PGNet算法](./doc/doc_ch/pgnet.md)
|
||||
- 模型训练
|
||||
- 数据集
|
||||
- [通用中英文OCR数据集](./doc/doc_ch/datasets.md)
|
||||
- [手写中文OCR数据集](./doc/doc_ch/handwritten_datasets.md)
|
||||
- [垂类多语言OCR数据集](./doc/doc_ch/vertical_and_multilingual_datasets.md)
|
||||
- [效果展示](#效果展示)
|
||||
- FAQ
|
||||
- [【精选】OCR精选10个问题](./doc/doc_ch/FAQ.md)
|
||||
|
@ -111,6 +114,7 @@ PaddleOCR同时支持动态图与静态图两种编程范式
|
|||
- [参考文献](./doc/doc_ch/reference.md)
|
||||
- [许可证书](#许可证书)
|
||||
- [贡献代码](#贡献代码)
|
||||
- [代码组织结构](./doc/doc_ch/tree.md)
|
||||
|
||||
|
||||
<a name="PP-OCR"></a>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
## 可选参数列表
|
||||
# 配置文件内容与生成
|
||||
|
||||
[toc]
|
||||
|
||||
## 1. 可选参数列表
|
||||
|
||||
以下列表可以通过`--help`查看
|
||||
|
||||
|
@ -8,10 +12,10 @@
|
|||
| -o | ALL | 设置配置文件里的参数内容 | None | 使用-o配置相较于-c选择的配置文件具有更高的优先级。例如:`-o Global.use_gpu=false` |
|
||||
|
||||
|
||||
## 配置文件参数介绍
|
||||
## 2. 配置文件参数介绍
|
||||
|
||||
以 `rec_chinese_lite_train_v2.0.yml ` 为例
|
||||
### Global
|
||||
### 2.1 Global
|
||||
|
||||
| 字段 | 用途 | 默认值 | 备注 |
|
||||
| :----------------------: | :---------------------: | :--------------: | :--------------------: |
|
||||
|
@ -121,3 +125,7 @@
|
|||
| batch_size_per_card | 训练时单卡batch size | 256 | \ |
|
||||
| drop_last | 是否丢弃因数据集样本数不能被 batch_size 整除而产生的最后一个不完整的mini-batch | True | \ |
|
||||
| num_workers | 用于加载数据的子进程个数,若为0即为不开启子进程,在主进程中进行数据加载 | 8 | \ |
|
||||
|
||||
## 3. 多语言配置文件生成
|
||||
|
||||
【参考识别模型训练补充内容】
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
# 零基础Python环境搭建
|
||||
|
||||
[toc]
|
||||
|
||||
## Windows
|
||||
|
||||
### 第1步:安装Anaconda
|
||||
|
||||
- 说明:使用paddlepaddle需要先安装python环境,这里我们选择python集成环境Anaconda工具包
|
||||
- Anaconda是1个常用的python包管理程序
|
||||
- 安装完Anaconda后,可以安装python环境,以及numpy等所需的工具包环境。
|
||||
- Anaconda下载:
|
||||
- 地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
|
||||
- 大部分win10电脑均为64位操作系统,选择x86_64版本;若电脑为32位操作系统,则选择x86.exe
|
||||
|
||||
<img src="../install/windows/Anaconda_download.png" alt="anaconda download" width="800" align="left"/>
|
||||
- 下载完成后,双击安装程序进入图形界面
|
||||
- 默认安装位置为C盘,建议将安装位置更改到D盘:
|
||||
|
||||
<img src="../install/windows/anaconda_install_folder.png" alt="install config" width="500" align="left"/>
|
||||
- 勾选conda加入环境变量,忽略警告:
|
||||
|
||||
<img src="../install/windows/anaconda_install_env.png" alt="add conda to path" width="500" align="left"/>
|
||||
|
||||
### 第2步:打开终端并创建conda环境
|
||||
|
||||
- 打开Anaconda Prompt终端:左下角Windows Start Menu -> Anaconda3 -> Anaconda Prompt启动控制台
|
||||
|
||||
<img src="../install/windows/anaconda_prompt.png" alt="anaconda download" width="300" align="left"/>
|
||||
|
||||
|
||||
- 创建新的conda环境
|
||||
|
||||
```shell
|
||||
# 在命令行输入以下命令,创建名为paddle_env的环境
|
||||
# 此处为加速下载,使用清华源
|
||||
conda create --name paddle_env python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ # 这是一行命令
|
||||
```
|
||||
|
||||
该命令会创建1个名为paddle_env、python版本为3.8的可执行环境,根据网络状态,需要花费一段时间
|
||||
|
||||
之后命令行中会输出提示信息,输入y并回车继续安装
|
||||
|
||||
<img src="../install/windows/conda_new_env.png" alt="conda create" width="700" align="left"/>
|
||||
|
||||
- 激活刚创建的conda环境,在命令行中输入以下命令:
|
||||
|
||||
```shell
|
||||
# 激活paddle_env环境
|
||||
conda activate paddle_env
|
||||
# 查看当前python的位置
|
||||
where python
|
||||
```
|
||||
|
||||
<img src="../install/windows/conda_list_env.png" alt="create environment" width="600" align="left"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
以上anaconda环境和python环境安装完毕
|
||||
|
||||
|
||||
|
||||
## Mac
|
||||
|
||||
### 第1步:安装Anaconda
|
||||
|
||||
- 说明:使用paddlepaddle需要先安装python环境,这里我们选择python集成环境Anaconda工具包
|
||||
- Anaconda是1个常用的python包管理程序
|
||||
- 安装完Anaconda后,可以安装python环境,以及numpy等所需的工具包环境
|
||||
- Anaconda下载:
|
||||
- 地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
|
||||
|
||||
<img src="../install/mac/anaconda_start.png" alt="anaconda download" width="800" align="left"/>
|
||||
|
||||
- 选择最下方的`Anaconda3-2021.05-MacOSX-x86_64.pkg`下载
|
||||
- 下载完成后,双击.pkg文件进入图形界面
|
||||
- 按默认设置即可,安装需要花费一段时间
|
||||
- 建议安装vscode或pycharm等代码编辑器
|
||||
|
||||
### 第2步:打开终端并创建conda环境
|
||||
|
||||
- 打开终端
|
||||
|
||||
- 同时按下command键和空格键,在聚焦搜索中输入"终端",双击进入终端
|
||||
|
||||
- **将conda加入环境变量**
|
||||
|
||||
- 加入环境变量是为了让系统能识别conda命令
|
||||
|
||||
- 输入以下命令,在终端中打开`~/.bash_profile`:
|
||||
|
||||
```shell
|
||||
vim ~/.bash_profile
|
||||
```
|
||||
|
||||
- 在`~/.bash_profile`中将conda添加为环境变量:
|
||||
|
||||
```shell
|
||||
# 先按i进入编辑模式
|
||||
# 在第一行输入:
|
||||
export PATH="~/opt/anaconda3/bin:$PATH"
|
||||
# 若安装时自定义了安装位置,则将~/opt/anaconda3/bin改为自定义的安装目录下的bin文件夹
|
||||
```
|
||||
|
||||
```shell
|
||||
# 修改后的~/.bash_profile文件应如下(其中xxx为用户名):
|
||||
export PATH="~/opt/anaconda3/bin:$PATH"
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
__conda_setup="$('/Users/xxx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="/Users/xxx/opt/anaconda3/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
# <<< conda initialize <<<
|
||||
```
|
||||
|
||||
- 修改完成后,先按`esc`键退出编辑模式,再输入`:wq!`并回车,以保存退出
|
||||
|
||||
- 验证是否能识别conda命令:
|
||||
|
||||
- 在终端中输入`source ~/.bash_profile`以更新环境变量
|
||||
- 再在终端输入`conda info --envs`,若能显示当前有base环境,则conda已加入环境变量
|
||||
|
||||
- 创建新的conda环境
|
||||
|
||||
```shell
|
||||
# 在命令行输入以下命令,创建名为paddle_env的环境
|
||||
# 此处为加速下载,使用清华源
|
||||
conda create --name paddle_env python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
```
|
||||
|
||||
- 该命令会创建1个名为paddle_env、python版本为3.8的可执行环境,根据网络状态,需要花费一段时间
|
||||
|
||||
- 之后命令行中会输出提示信息,输入y并回车继续安装
|
||||
|
||||
- <img src="../install/mac/conda_create.png" alt="conda_create" width="600" align="left"/>
|
||||
|
||||
- 激活刚创建的conda环境,在命令行中输入以下命令:
|
||||
|
||||
```shell
|
||||
# 激活paddle_env环境
|
||||
conda activate paddle_env
|
||||
# 查看当前python的位置
|
||||
where python
|
||||
```
|
||||
|
||||
<img src="../install/mac/conda_activate.png" alt="conda_actviate" width="600" align="left"/>
|
||||
|
||||
以上anaconda环境和python环境安装完毕
|
||||
|
||||
|
||||
|
||||
## Linux
|
||||
|
||||
### 第1步:安装Anaconda
|
||||
|
||||
- 说明:使用paddlepaddle需要先安装python环境,这里我们选择python集成环境Anaconda工具包
|
||||
- Anaconda是1个常用的python包管理程序
|
||||
- 安装完Anaconda后,可以安装python环境,以及numpy等所需的工具包环境
|
||||
|
||||
- **下载Anaconda**:
|
||||
|
||||
- 下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
|
||||
<img src="../install/linux/anaconda_download.png" akt="anaconda download" width="800" align="left"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- 选择适合您操作系统的版本
|
||||
- 可在终端输入`uname -m`查询系统所用的指令集
|
||||
|
||||
- 下载法1:本地下载,再将安装包传到linux服务器上
|
||||
|
||||
- 下载法2:直接使用linux命令行下载
|
||||
|
||||
```shell
|
||||
# 首先安装wget
|
||||
sudo apt-get install wget # Ubuntu
|
||||
sudo yum install wget # CentOS
|
||||
```
|
||||
|
||||
```shell
|
||||
# 然后使用wget从清华源上下载
|
||||
# 如要下载Anaconda3-2021.05-Linux-x86_64.sh,则下载命令如下:
|
||||
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh
|
||||
|
||||
# 若您要下载其他版本,需要将最后1个/后的文件名改成您希望下载的版本
|
||||
```
|
||||
|
||||
- 安装Anaconda:
|
||||
|
||||
- 在命令行输入`sh Anaconda3-2021.05-Linux-x86_64.sh`
|
||||
- 若您下载的是其它版本,则将该命令的文件名替换为您下载的文件名
|
||||
- 按照安装提示安装即可
|
||||
- 查看许可时可输入q来退出
|
||||
|
||||
- **将conda加入环境变量**
|
||||
|
||||
- 加入环境变量是为了让系统能识别conda命令,若您在安装时已将conda加入环境变量path,则可跳过本步
|
||||
|
||||
- 在终端中打开`~/.bashrc`:
|
||||
|
||||
```shell
|
||||
# 在终端中输入以下命令:
|
||||
vim ~/.bashrc
|
||||
```
|
||||
|
||||
- 在`~/.bashrc`中将conda添加为环境变量:
|
||||
|
||||
```shell
|
||||
# 先按i进入编辑模式
|
||||
# 在第一行输入:
|
||||
export PATH="~/anaconda3/bin:$PATH"
|
||||
# 若安装时自定义了安装位置,则将~/anaconda3/bin改为自定义的安装目录下的bin文件夹
|
||||
```
|
||||
|
||||
```shell
|
||||
# 修改后的~/.bash_profile文件应如下(其中xxx为用户名):
|
||||
export PATH="~/opt/anaconda3/bin:$PATH"
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
__conda_setup="$('/Users/xxx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="/Users/xxx/opt/anaconda3/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
# <<< conda initialize <<<
|
||||
```
|
||||
|
||||
- 修改完成后,先按`esc`键退出编辑模式,再输入`:wq!`并回车,以保存退出
|
||||
|
||||
- 验证是否能识别conda命令:
|
||||
|
||||
- 在终端中输入`source ~/.bash_profile`以更新环境变量
|
||||
- 再在终端输入`conda info --envs`,若能显示当前有base环境,则conda已加入环境变量
|
||||
|
||||
### 第2步:创建conda环境
|
||||
|
||||
- 创建新的conda环境
|
||||
|
||||
```shell
|
||||
# 在命令行输入以下命令,创建名为paddle_env的环境
|
||||
# 此处为加速下载,使用清华源
|
||||
conda create --name paddle_env python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
```
|
||||
|
||||
- 该命令会创建1个名为paddle_env、python版本为3.8的可执行环境,根据网络状态,需要花费一段时间
|
||||
|
||||
- 之后命令行中会输出提示信息,输入y并回车继续安装
|
||||
|
||||
<img src="../install/linux/conda_create.png" alt="conda_create" width="500" align="left"/>
|
||||
|
||||
- 激活刚创建的conda环境,在命令行中输入以下命令:
|
||||
|
||||
```shell
|
||||
# 激活paddle_env环境
|
||||
conda activate paddle_env
|
||||
```
|
||||
|
||||
|
||||
以上anaconda环境和python环境安装完毕
|
|
@ -200,9 +200,9 @@ ppocr 支持使用自己的数据进行自定义训练或finetune, 其中识别
|
|||
|英文|english|en| |乌克兰文|Ukranian|uk|
|
||||
|法文|french|fr| |白俄罗斯文|Belarusian|be|
|
||||
|德文|german|german| |泰卢固文|Telugu |te|
|
||||
|日文|japan|japan| | |阿巴扎文|Abaza |abq|
|
||||
|日文|japan|japan| | 阿巴扎文 | Abaza | abq |
|
||||
|韩文|korean|korean| |泰米尔文|Tamil |ta|
|
||||
|中文繁体|chinese traditional |ch_tra| |南非荷兰文 |Afrikaans |af|
|
||||
|中文繁体|chinese traditional |chinese_cht| |南非荷兰文 |Afrikaans |af|
|
||||
|意大利文| Italian |it| |阿塞拜疆文 |Azerbaijani |az|
|
||||
|西班牙文|Spanish |es| |波斯尼亚文|Bosnian|bs|
|
||||
|葡萄牙文| Portuguese|pt| |捷克文|Czech|cs|
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# PaddleOCR全景图与项目克隆
|
||||
|
|
@ -1,100 +1,268 @@
|
|||
# PaddleOCR快速开始
|
||||
|
||||
# 中文OCR模型快速使用
|
||||
|
||||
## 1.环境配置
|
||||
|
||||
请先参考[快速安装](./installation.md)配置PaddleOCR运行环境。
|
||||
|
||||
*注意:也可以通过 whl 包安装使用PaddleOCR,具体参考[Paddleocr Package使用说明](./whl.md)。*
|
||||
|
||||
## 2.inference模型下载
|
||||
|
||||
* 移动端和服务器端的检测与识别模型如下,更多模型下载(包括多语言),可以参考[PP-OCR v2.0 系列模型下载](../doc_ch/models_list.md)
|
||||
|
||||
| 模型简介 | 模型名称 |推荐场景 | 检测模型 | 方向分类器 | 识别模型 |
|
||||
| ------------ | --------------- | ----------------|---- | ---------- | -------- |
|
||||
| 中英文超轻量OCR模型(8.1M) | ch_ppocr_mobile_v2.0_xx |移动端&服务器端|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar)|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar) |[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_pre.tar) |
|
||||
| 中英文通用OCR模型(143M) | ch_ppocr_server_v2.0_xx |服务器端 |[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar) |[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar) |[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar) / [预训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_pre.tar) |
|
||||
[TOC]
|
||||
|
||||
|
||||
* windows 环境下如果没有安装wget,下载模型时可将链接复制到浏览器中下载,并解压放置在相应目录下
|
||||
## 1. 轻量安装
|
||||
|
||||
复制上表中的检测和识别的`inference模型`下载地址,并解压
|
||||
### 1.0 运行环境准备
|
||||
|
||||
```
|
||||
mkdir inference && cd inference
|
||||
# 下载检测模型并解压
|
||||
wget {url/of/detection/inference_model} && tar xf {name/of/detection/inference_model/package}
|
||||
# 下载识别模型并解压
|
||||
wget {url/of/recognition/inference_model} && tar xf {name/of/recognition/inference_model/package}
|
||||
# 下载方向分类器模型并解压
|
||||
wget {url/of/classification/inference_model} && tar xf {name/of/classification/inference_model/package}
|
||||
cd ..
|
||||
```
|
||||
如果您未搭建过Python环境,可以通过[零基础Python环境搭建文档](./environment.)进行环境搭建
|
||||
|
||||
以超轻量级模型为例:
|
||||
### 1.1 安装PaddlePaddle2.0
|
||||
|
||||
```
|
||||
mkdir inference && cd inference
|
||||
# 下载超轻量级中文OCR模型的检测模型并解压
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_det_infer.tar
|
||||
# 下载超轻量级中文OCR模型的识别模型并解压
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar
|
||||
# 下载超轻量级中文OCR模型的文本方向分类器模型并解压
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar && tar xf ch_ppocr_mobile_v2.0_cls_infer.tar
|
||||
cd ..
|
||||
```
|
||||
|
||||
解压完毕后应有如下文件结构:
|
||||
|
||||
```
|
||||
├── ch_ppocr_mobile_v2.0_cls_infer
|
||||
│ ├── inference.pdiparams
|
||||
│ ├── inference.pdiparams.info
|
||||
│ └── inference.pdmodel
|
||||
├── ch_ppocr_mobile_v2.0_det_infer
|
||||
│ ├── inference.pdiparams
|
||||
│ ├── inference.pdiparams.info
|
||||
│ └── inference.pdmodel
|
||||
├── ch_ppocr_mobile_v2.0_rec_infer
|
||||
├── inference.pdiparams
|
||||
├── inference.pdiparams.info
|
||||
└── inference.pdmodel
|
||||
```
|
||||
|
||||
## 3.单张图像或者图像集合预测
|
||||
|
||||
以下代码实现了文本检测、方向分类器和识别串联推理,在执行预测时,需要通过参数image_dir指定单张图像或者图像集合的路径、参数`det_model_dir`指定检测inference模型的路径、参数`rec_model_dir`指定识别inference模型的路径、参数`use_angle_cls`指定是否使用方向分类器、参数`cls_model_dir`指定方向分类器inference模型的路径、参数`use_space_char`指定是否预测空格字符。可视化识别结果默认保存到`./inference_results`文件夹里面。
|
||||
- 如果您的机器安装的是CUDA9或CUDA10,请运行以下命令安装
|
||||
|
||||
```bash
|
||||
|
||||
# 预测image_dir指定的单张图像
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
|
||||
|
||||
# 预测image_dir指定的图像集合
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
|
||||
|
||||
# 如果想使用CPU进行预测,需设置use_gpu参数为False
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_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
|
||||
python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
|
||||
```
|
||||
|
||||
- 通用中文OCR模型
|
||||
|
||||
请按照上述步骤下载相应的模型,并且更新相关的参数,示例如下:
|
||||
- 如果您的机器是CPU,请运行以下命令安装
|
||||
|
||||
```bash
|
||||
# 预测image_dir指定的单张图像
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --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
|
||||
python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
|
||||
```
|
||||
|
||||
* 注意:
|
||||
- 如果希望使用不支持空格的识别模型,在预测的时候需要注意:请将代码更新到最新版本,并添加参数 `--use_space_char=False`。
|
||||
- 如果不希望使用方向分类器,在预测的时候需要注意:请将代码更新到最新版本,并添加参数 `--use_angle_cls=False`。
|
||||
更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。
|
||||
|
||||
### 1.2 安装PaddleOCR whl包
|
||||
|
||||
```bash
|
||||
pip install "paddleocr>=2.0.1" # 推荐使用2.0.1+版本
|
||||
```
|
||||
|
||||
- 对于Windows环境用户:
|
||||
|
||||
直接通过pip安装的shapely库可能出现`[winRrror 126] 找不到指定模块的问题`。建议从[这里](https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely)下载shapely安装包完成安装,
|
||||
|
||||
- 使用**版面分析**功能时,运行以下命令**安装 Layout-Parser**
|
||||
|
||||
```bash
|
||||
pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
|
||||
更多的文本检测、识别串联推理使用方式请参考文档教程中[基于Python预测引擎推理](./inference.md)。
|
||||
|
||||
此外,文档教程中也提供了中文OCR模型的其他预测部署方式:
|
||||
- [基于C++预测引擎推理](../../deploy/cpp_infer/readme.md)
|
||||
- [服务部署](../../deploy/hubserving)
|
||||
- [端侧部署(目前只支持静态图)](https://github.com/PaddlePaddle/PaddleOCR/tree/develop/deploy/lite)
|
||||
## 2. 便捷使用
|
||||
|
||||
### 2.1 命令行使用
|
||||
|
||||
PaddleOCR提供了一系列测试图片,点击xx下载,然后在终端中切换到相应目录
|
||||
|
||||
```
|
||||
cd /path/to/ppocr_img
|
||||
```
|
||||
|
||||
如果不使用提供的测试图片,可以将下方`--image_dir`参数替换为相应的测试图片路径
|
||||
|
||||
#### 2.1.1 中英文模型
|
||||
|
||||
* 检测+方向分类器+识别全流程:设置方向分类器参数`--use_angle_cls true`后可对竖排文本进行识别。
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir ./imgs/11.jpg --use_angle_cls true
|
||||
```
|
||||
|
||||
结果是一个list,每个item包含了文本框,文字和识别置信度
|
||||
|
||||
```bash
|
||||
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
|
||||
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
|
||||
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
|
||||
......
|
||||
```
|
||||
|
||||
- 单独使用检测:设置`--rec`为`false`
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir ./imgs/11.jpg --rec false
|
||||
```
|
||||
|
||||
结果是一个list,每个item只包含文本框
|
||||
|
||||
```bash
|
||||
[[26.0, 457.0], [137.0, 457.0], [137.0, 477.0], [26.0, 477.0]]
|
||||
[[25.0, 425.0], [372.0, 425.0], [372.0, 448.0], [25.0, 448.0]]
|
||||
[[128.0, 397.0], [273.0, 397.0], [273.0, 414.0], [128.0, 414.0]]
|
||||
......
|
||||
```
|
||||
|
||||
- 单独使用识别:设置`--det`为`false`
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir ./imgs_words/ch/word_1.jpg --det false
|
||||
```
|
||||
|
||||
结果是一个list,每个item只包含识别结果和识别置信度
|
||||
|
||||
```bash
|
||||
['韩国小馆', 0.9907421]
|
||||
```
|
||||
|
||||
|
||||
更多whl包使用包括, whl包参数说明
|
||||
|
||||
|
||||
|
||||
#### 2.1.2 多语言模型
|
||||
|
||||
Paddleocr目前支持80个语种,可以通过修改`--lang`参数进行切换,对于英文模型,指定`--lang=en`。
|
||||
|
||||
``` bash
|
||||
paddleocr --image_dir ./imgs_en/254.jpg --lang=en
|
||||
```
|
||||
|
||||
<div align="center">
|
||||
<img src="../imgs_en/254.jpg" width="300" height="600">
|
||||
<img src="../imgs_results/multi_lang/img_02.jpg" width="600" height="600">
|
||||
</div>
|
||||
|
||||
结果是一个list,每个item包含了文本框,文字和识别置信度
|
||||
|
||||
```text
|
||||
[('PHO CAPITAL', 0.95723116), [[66.0, 50.0], [327.0, 44.0], [327.0, 76.0], [67.0, 82.0]]]
|
||||
[('107 State Street', 0.96311164), [[72.0, 90.0], [451.0, 84.0], [452.0, 116.0], [73.0, 121.0]]]
|
||||
[('Montpelier Vermont', 0.97389287), [[69.0, 132.0], [501.0, 126.0], [501.0, 158.0], [70.0, 164.0]]]
|
||||
[('8022256183', 0.99810505), [[71.0, 175.0], [363.0, 170.0], [364.0, 202.0], [72.0, 207.0]]]
|
||||
[('REG 07-24-201706:59 PM', 0.93537045), [[73.0, 299.0], [653.0, 281.0], [654.0, 318.0], [74.0, 336.0]]]
|
||||
[('045555', 0.99346405), [[509.0, 331.0], [651.0, 325.0], [652.0, 356.0], [511.0, 362.0]]]
|
||||
[('CT1', 0.9988654), [[535.0, 367.0], [654.0, 367.0], [654.0, 406.0], [535.0, 406.0]]]
|
||||
......
|
||||
```
|
||||
|
||||
常用的多语言简写包括
|
||||
|
||||
| 语种 | 缩写 | | 语种 | 缩写 | | 语种 | 缩写 |
|
||||
| -------- | ----------- | ---- | -------- | ------ | ---- | -------- | ------ |
|
||||
| 中文 | ch | | 法文 | fr | | 日文 | japan |
|
||||
| 英文 | en | | 德文 | german | | 韩文 | korean |
|
||||
| 繁体中文 | chinese_cht | | 意大利文 | it | | 俄罗斯文 | ru |
|
||||
|
||||
全部语种及其对应的缩写列表可查看[多语言模型教程](./multi_languages.md)
|
||||
|
||||
#### 2.1.3 版面分析
|
||||
|
||||
使用PaddleOCR的版面分析功能,需要指定`--type=structure`
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir=./table/1.png --type=structure
|
||||
```
|
||||
|
||||
- **返回结果说明**
|
||||
|
||||
PP-Structure的返回结果为一个dict组成的list,示例如下
|
||||
|
||||
```shell
|
||||
[{ 'type': 'Text',
|
||||
'bbox': [34, 432, 345, 462],
|
||||
'res': ([[36.0, 437.0, 341.0, 437.0, 341.0, 446.0, 36.0, 447.0], [41.0, 454.0, 125.0, 453.0, 125.0, 459.0, 41.0, 460.0]],
|
||||
[('Tigure-6. The performance of CNN and IPT models using difforen', 0.90060663), ('Tent ', 0.465441)])
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
其中各个字段说明如下
|
||||
|
||||
| 字段 | 说明 |
|
||||
| ---- | ------------------------------------------------------------ |
|
||||
| type | 图片区域的类型 |
|
||||
| bbox | 图片区域的在原图的坐标,分别[左上角x,左上角y,右下角x,右下角y] |
|
||||
| res | 图片区域的OCR或表格识别结果。<br>表格: 表格的HTML字符串; <br>OCR: 一个包含各个单行文字的检测坐标和识别结果的元组 |
|
||||
|
||||
运行完成后,每张图片会在`output`字段指定的目录下有一个同名目录,图片里的每个表格会存储为一个excel,图片区域会被裁剪之后保存下来,excel文件和图片名为表格在图片里的坐标。
|
||||
|
||||
```
|
||||
/output/table/1/
|
||||
└─ res.txt
|
||||
└─ [454, 360, 824, 658].xlsx 表格识别结果
|
||||
└─ [16, 2, 828, 305].jpg 被裁剪出的图片区域
|
||||
└─ [17, 361, 404, 711].xlsx 表格识别结果
|
||||
```
|
||||
|
||||
- **参数说明**
|
||||
|
||||
| 字段 | 说明 | 默认值 |
|
||||
| --------------- | ---------------------------------------- | -------------------------------------------- |
|
||||
| output | excel和识别结果保存的地址 | ./output/table |
|
||||
| table_max_len | 表格结构模型预测时,图像的长边resize尺度 | 488 |
|
||||
| table_model_dir | 表格结构模型 inference 模型地址 | None |
|
||||
| table_char_type | 表格结构模型所用字典地址 | ../ppocr/utils/dict/table_structure_dict.txt |
|
||||
|
||||
大部分参数和paddleocr whl包保持一致,见 [whl包文档](../doc/doc_ch/whl.md)
|
||||
|
||||
|
||||
|
||||
### 2.2 Python脚本使用
|
||||
|
||||
#### 2.2.1 中英文与多语言使用
|
||||
|
||||
通过脚本使用PaddleOCR whl包。whl包会自动下载ppocr轻量级模型作为默认模型,
|
||||
|
||||
* 检测+方向分类器+识别全流程
|
||||
|
||||
```python
|
||||
from paddleocr import PaddleOCR, draw_ocr
|
||||
|
||||
# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
|
||||
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
|
||||
ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
|
||||
img_path = './imgs/11.jpg'
|
||||
result = ocr.ocr(img_path, cls=True)
|
||||
for line in result:
|
||||
print(line)
|
||||
|
||||
# 显示结果
|
||||
from PIL import Image
|
||||
|
||||
image = Image.open(img_path).convert('RGB')
|
||||
boxes = [line[0] for line in result]
|
||||
txts = [line[1][0] for line in result]
|
||||
scores = [line[1][1] for line in result]
|
||||
im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/simfang.ttf')
|
||||
im_show = Image.fromarray(im_show)
|
||||
im_show.save('result.jpg')
|
||||
```
|
||||
|
||||
结果是一个list,每个item包含了文本框,文字和识别置信度
|
||||
|
||||
```bash
|
||||
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
|
||||
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
|
||||
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
|
||||
......
|
||||
```
|
||||
|
||||
结果可视化
|
||||
|
||||
<div align="center">
|
||||
<img src="../imgs_results/whl/11_det_rec.jpg" width="800">
|
||||
</div>
|
||||
|
||||
#### 2.2.2 版面分析使用
|
||||
|
||||
```python
|
||||
import os
|
||||
import cv2
|
||||
from paddleocr import PPStructure,draw_structure_result,save_structure_res
|
||||
|
||||
table_engine = PPStructure(show_log=True)
|
||||
|
||||
save_folder = './output/table'
|
||||
img_path = './table/paper-image.jpg'
|
||||
img = cv2.imread(img_path)
|
||||
result = table_engine(img)
|
||||
save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])
|
||||
|
||||
for line in result:
|
||||
line.pop('img')
|
||||
print(line)
|
||||
|
||||
from PIL import Image
|
||||
|
||||
font_path = './fonts/simfang.ttf' # PaddleOCR下提供字体包
|
||||
image = Image.open(img_path).convert('RGB')
|
||||
im_show = draw_structure_result(image, result,font_path=font_path)
|
||||
im_show = Image.fromarray(im_show)
|
||||
im_show.save('result.jpg')
|
||||
```
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true
|
|||
```bash
|
||||
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
|
||||
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
|
||||
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
|
||||
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]µ
|
||||
......
|
||||
```
|
||||
|
||||
|
|
|
@ -1,103 +1,184 @@
|
|||
|
||||
# Quick start of Chinese OCR model
|
||||
# PaddleOCR Quick Start
|
||||
|
||||
## 1. Prepare for the environment
|
||||
[TOC]
|
||||
|
||||
Please refer to [quick installation](./installation_en.md) to configure the PaddleOCR operating environment.
|
||||
## 1. 轻量安装
|
||||
|
||||
* Note: Support the use of PaddleOCR through whl package installation,pelease refer [PaddleOCR Package](./whl_en.md).
|
||||
|
||||
## 2.inference models
|
||||
|
||||
The detection and recognition models on the mobile and server sides are as follows. For more models (including multiple languages), please refer to [PP-OCR v2.0 series model list](../doc_ch/models_list.md)
|
||||
|
||||
| Model introduction | Model name | Recommended scene | Detection model | Direction Classifier | Recognition model |
|
||||
| ------------ | --------------- | ----------------|---- | ---------- | -------- |
|
||||
| Ultra-lightweight Chinese OCR model (8.1M) | ch_ppocr_mobile_v2.0_xx |Mobile-side/Server-side|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar)|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar) |[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_pre.tar) |
|
||||
| Universal Chinese OCR model (143M) | ch_ppocr_server_v2.0_xx |Server-side |[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar) |[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar) |[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar) / [pretrained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_pre.tar) |
|
||||
|
||||
|
||||
* If `wget` is not installed in the windows environment, you can copy the link to the browser to download when downloading the model, then uncompress it and place it in the corresponding directory.
|
||||
|
||||
Copy the download address of the `inference model` for detection and recognition in the table above, and uncompress them.
|
||||
|
||||
```
|
||||
mkdir inference && cd inference
|
||||
# Download the detection model and unzip
|
||||
wget {url/of/detection/inference_model} && tar xf {name/of/detection/inference_model/package}
|
||||
# Download the recognition model and unzip
|
||||
wget {url/of/recognition/inference_model} && tar xf {name/of/recognition/inference_model/package}
|
||||
# Download the direction classifier model and unzip
|
||||
wget {url/of/classification/inference_model} && tar xf {name/of/classification/inference_model/package}
|
||||
cd ..
|
||||
```
|
||||
|
||||
Take the ultra-lightweight model as an example:
|
||||
|
||||
```
|
||||
mkdir inference && cd inference
|
||||
# Download the detection model of the ultra-lightweight Chinese OCR model and uncompress it
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_det_infer.tar
|
||||
# Download the recognition model of the ultra-lightweight Chinese OCR model and uncompress it
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar
|
||||
# Download the angle classifier model of the ultra-lightweight Chinese OCR model and uncompress it
|
||||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar && tar xf ch_ppocr_mobile_v2.0_cls_infer.tar
|
||||
cd ..
|
||||
```
|
||||
|
||||
After decompression, the file structure should be as follows:
|
||||
|
||||
```
|
||||
├── ch_ppocr_mobile_v2.0_cls_infer
|
||||
│ ├── inference.pdiparams
|
||||
│ ├── inference.pdiparams.info
|
||||
│ └── inference.pdmodel
|
||||
├── ch_ppocr_mobile_v2.0_det_infer
|
||||
│ ├── inference.pdiparams
|
||||
│ ├── inference.pdiparams.info
|
||||
│ └── inference.pdmodel
|
||||
├── ch_ppocr_mobile_v2.0_rec_infer
|
||||
├── inference.pdiparams
|
||||
├── inference.pdiparams.info
|
||||
└── inference.pdmodel
|
||||
```
|
||||
|
||||
## 3. Single image or image set prediction
|
||||
|
||||
* The following code implements text detection、angle class and recognition process. When performing prediction, you need to specify the path of a single image or image set through the parameter `image_dir`, the parameter `det_model_dir` specifies the path to detect the inference model, the parameter `rec_model_dir` specifies the path to identify the inference model, the parameter `use_angle_cls` specifies whether to use the direction classifier, the parameter `cls_model_dir` specifies the path to identify the direction classifier model, the parameter `use_space_char` specifies whether to predict the space char. The visual results are saved to the `./inference_results` folder by default.
|
||||
### 1.0 Environment Preparation
|
||||
|
||||
环境配置
|
||||
|
||||
python环境、pip安装
|
||||
|
||||
```bash
|
||||
|
||||
# Predict a single image specified by image_dir
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
|
||||
|
||||
# Predict imageset specified by image_dir
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
|
||||
|
||||
# If you want to use the CPU for prediction, you need to set the use_gpu parameter to False
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_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
|
||||
pip3 install --upgrade pip
|
||||
```
|
||||
|
||||
- Universal Chinese OCR model
|
||||
### 1.1 Install PaddlePaddle2.0
|
||||
|
||||
Please follow the above steps to download the corresponding models and update the relevant parameters, The example is as follows.
|
||||
```bash
|
||||
# If you have cuda9 or cuda10 installed on your machine, please run the following command to install
|
||||
python3 -m pip install paddlepaddle-gpu==2.0.0 -i https://mirror.baidu.com/pypi/simple
|
||||
|
||||
```
|
||||
# Predict a single image specified by image_dir
|
||||
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --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
|
||||
# If you only have cpu on your machine, please run the following command to install
|
||||
python3 -m pip install paddlepaddle==2.0.0 -i https://mirror.baidu.com/pypi/simple
|
||||
```
|
||||
|
||||
* Note
|
||||
- If you want to use the recognition model which does not support space char recognition, please update the source code to the latest version and add parameters `--use_space_char=False`.
|
||||
- If you do not want to use direction classifier, please update the source code to the latest version and add parameters `--use_angle_cls=False`.
|
||||
For more software version requirements, please refer to the instructions in [Installation Document](https://www.paddlepaddle.org.cn/install/quick) for operation.
|
||||
|
||||
### 1.2 Install PaddleOCR Whl Package
|
||||
|
||||
```bash
|
||||
pip install "paddleocr>=2.0.1" # Recommend to use version 2.0.1+
|
||||
```
|
||||
|
||||
是否会出现sharply问题?
|
||||
|
||||
|
||||
For more text detection and recognition tandem reasoning, please refer to the document tutorial
|
||||
: [Inference with Python inference engine](./inference_en.md)。
|
||||
|
||||
In addition, the tutorial also provides other deployment methods for the Chinese OCR model:
|
||||
- [Server-side C++ inference](../../deploy/cpp_infer/readme_en.md)
|
||||
- [Service deployment](../../deploy/hubserving)
|
||||
- [End-to-end deployment](https://github.com/PaddlePaddle/PaddleOCR/tree/develop/deploy/lite)
|
||||
如果需要使用版面分析功能,还需**安装 Layout-Parser**
|
||||
|
||||
```bash
|
||||
pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
## 2. 便捷使用
|
||||
|
||||
### 2.1 Use by command line
|
||||
|
||||
#### 2.1.1 English and Chinese Model
|
||||
|
||||
* detection classification and recognition
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --use_angle_cls true --lang en
|
||||
```
|
||||
|
||||
Output will be a list, each item contains bounding box, text and recognition confidence
|
||||
|
||||
```bash
|
||||
[[[442.0, 173.0], [1169.0, 173.0], [1169.0, 225.0], [442.0, 225.0]], ['ACKNOWLEDGEMENTS', 0.99283075]]
|
||||
[[[393.0, 340.0], [1207.0, 342.0], [1207.0, 389.0], [393.0, 387.0]], ['We would like to thank all the designers and', 0.9357758]]
|
||||
[[[399.0, 398.0], [1204.0, 398.0], [1204.0, 433.0], [399.0, 433.0]], ['contributors whohave been involved in the', 0.9592447]]
|
||||
......
|
||||
```
|
||||
|
||||
* 更多whl包使用包括, whl包参数说明:
|
||||
|
||||
#### 2.1.2 Multi-language Model
|
||||
|
||||
Paddleocr currently supports 80 languages, which can be switched by modifying the --lang parameter.The specific supported [language](language_abbreviations) can be viewed in the table.
|
||||
|
||||
``` bash
|
||||
paddleocr --image_dir ./doc/imgs_en/254.jpg --lang=en
|
||||
```
|
||||
|
||||
<div align="center">
|
||||
<img src="../imgs_en/254.jpg" width="300" height="600">
|
||||
<img src="../imgs_results/multi_lang/img_02.jpg" width="600" height="600">
|
||||
</div>
|
||||
|
||||
|
||||
The result is a list, each item contains a text box, text and recognition confidence
|
||||
|
||||
```text
|
||||
[('PHO CAPITAL', 0.95723116), [[66.0, 50.0], [327.0, 44.0], [327.0, 76.0], [67.0, 82.0]]]
|
||||
[('107 State Street', 0.96311164), [[72.0, 90.0], [451.0, 84.0], [452.0, 116.0], [73.0, 121.0]]]
|
||||
[('Montpelier Vermont', 0.97389287), [[69.0, 132.0], [501.0, 126.0], [501.0, 158.0], [70.0, 164.0]]]
|
||||
[('8022256183', 0.99810505), [[71.0, 175.0], [363.0, 170.0], [364.0, 202.0], [72.0, 207.0]]]
|
||||
[('REG 07-24-201706:59 PM', 0.93537045), [[73.0, 299.0], [653.0, 281.0], [654.0, 318.0], [74.0, 336.0]]]
|
||||
[('045555', 0.99346405), [[509.0, 331.0], [651.0, 325.0], [652.0, 356.0], [511.0, 362.0]]]
|
||||
[('CT1', 0.9988654), [[535.0, 367.0], [654.0, 367.0], [654.0, 406.0], [535.0, 406.0]]]
|
||||
......
|
||||
```
|
||||
|
||||
#### 2.1.3 版面分析
|
||||
|
||||
```bash
|
||||
paddleocr --image_dir=../doc/table/1.png --type=structure
|
||||
```
|
||||
|
||||
1. **返回结果说明**
|
||||
|
||||
PP-Structure的返回结果为一个dict组成的list,示例如下
|
||||
|
||||
```shell
|
||||
[
|
||||
{ 'type': 'Text',
|
||||
'bbox': [34, 432, 345, 462],
|
||||
'res': ([[36.0, 437.0, 341.0, 437.0, 341.0, 446.0, 36.0, 447.0], [41.0, 454.0, 125.0, 453.0, 125.0, 459.0, 41.0, 460.0]],
|
||||
[('Tigure-6. The performance of CNN and IPT models using difforen', 0.90060663), ('Tent ', 0.465441)])
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
dict 里各个字段说明如下
|
||||
|
||||
| 字段 | 说明 |
|
||||
| ---- | ------------------------------------------------------------ |
|
||||
| type | 图片区域的类型 |
|
||||
| bbox | 图片区域的在原图的坐标,分别[左上角x,左上角y,右下角x,右下角y] |
|
||||
| res | 图片区域的OCR或表格识别结果。<br> 表格: 表格的HTML字符串; <br> OCR: 一个包含各个单行文字的检测坐标和识别结果的元组 |
|
||||
|
||||
2. **参数说明**
|
||||
|
||||
| 字段 | 说明 | 默认值 |
|
||||
| --------------- | ---------------------------------------- | -------------------------------------------- |
|
||||
| output | excel和识别结果保存的地址 | ./output/table |
|
||||
| table_max_len | 表格结构模型预测时,图像的长边resize尺度 | 488 |
|
||||
| table_model_dir | 表格结构模型 inference 模型地址 | None |
|
||||
| table_char_type | 表格结构模型所用字典地址 | ../ppocr/utils/dict/table_structure_dict.txt |
|
||||
|
||||
大部分参数和paddleocr whl包保持一致,见 [whl包文档](../doc/doc_ch/whl.md)
|
||||
|
||||
运行完成后,每张图片会在`output`字段指定的目录下有一个同名目录,图片里的每个表格会存储为一个excel,图片区域会被裁剪之后保存下来,excel文件和图片名名为表格在图片里的坐标。
|
||||
|
||||
### 2.2 Python脚本使用
|
||||
|
||||
#### 2.2.1 中英文与多语言使用
|
||||
|
||||
paddleocr whl包会自动下载ppocr轻量级模型作为默认模型,可以根据第3节**自定义模型**进行自定义更换。
|
||||
|
||||
* 检测+方向分类器+识别全流程
|
||||
|
||||
```python
|
||||
from paddleocr import PaddleOCR, draw_ocr
|
||||
|
||||
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
|
||||
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
|
||||
ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
|
||||
img_path = 'Path/to/Your/Img/11.jpg'
|
||||
result = ocr.ocr(img_path, cls=True)
|
||||
for line in result:
|
||||
print(line)
|
||||
|
||||
# 显示结果
|
||||
from PIL import Image
|
||||
|
||||
image = Image.open(img_path).convert('RGB')
|
||||
boxes = [line[0] for line in result]
|
||||
txts = [line[1][0] for line in result]
|
||||
scores = [line[1][1] for line in result]
|
||||
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
|
||||
im_show = Image.fromarray(im_show)
|
||||
im_show.save('result.jpg')
|
||||
```
|
||||
|
||||
结果是一个list,每个item包含了文本框,文字和识别置信度
|
||||
|
||||
```bash
|
||||
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
|
||||
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
|
||||
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
|
||||
......
|
||||
```
|
||||
|
||||
结果可视化
|
||||
|
||||
<div align="center">
|
||||
<img src="../imgs_results/whl/11_det_rec.jpg" width="800">
|
||||
</div>
|
||||
|
||||
|
||||
#### 2.2.2 版面分析使用
|
||||
|
|
BIN
doc/joinus.PNG
BIN
doc/joinus.PNG
Binary file not shown.
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 188 KiB |
Loading…
Reference in New Issue