Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#4044 from Evezerest/2.3
Browse files Browse the repository at this point in the history
Unified document title case
  • Loading branch information
Evezerest committed Sep 23, 2021
1 parent ba3e198 commit 93f5b68
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 170 deletions.
4 changes: 2 additions & 2 deletions PPOCRLabel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, w
pip3 install --upgrade pip

# 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
python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple

# 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
python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
```

For more software version requirements, please refer to the instructions in [Installation Document](https://www.paddlepaddle.org.cn/install/quick) for operation.
Expand Down
4 changes: 2 additions & 2 deletions PPOCRLabel/README_ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P
pip3 install --upgrade pip

如果您的机器安装的是CUDA9或CUDA10,请运行以下命令安装
python3 -m pip install paddlepaddle-gpu==2.0.0 -i https://mirror.baidu.com/pypi/simple
python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple

如果您的机器是CPU,请运行以下命令安装

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

更多的版本需求,请参照[安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Mobile DEMO experience (based on EasyEdge and Paddle-Lite, supports iOS and Andr
<a name="Supported-Chinese-model-list"></a>


## PP-OCR series model list(Update on September 8th)
## PP-OCR Series Model List(Update on September 8th)

| Model introduction | Model name | Recommended scene | Detection model | Direction classifier | Recognition model |
| ------------------------------------------------------------ | ---------------------------- | ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
Expand All @@ -107,7 +107,8 @@ For a new language request, please refer to [Guideline for new language_requests
- [PP-OCR Training](./doc/doc_en/training_en.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)
- [Text Direction Classification](./doc/doc_en/angle_class_en.md)
- [Yml Configuration](./doc/doc_en/config_en.md)
- Inference and Deployment
- [C++ Inference](./deploy/cpp_infer/readme_en.md)
- [Serving](./deploy/pdserving/README.md)
Expand Down Expand Up @@ -173,7 +174,7 @@ For a new language request, please refer to [Guideline for new language_requests


<a name="language_requests"></a>
## Guideline for new language requests
## Guideline for New Language Requests

If you want to request a new language support, a PR with 2 following files are needed:

Expand Down
3 changes: 2 additions & 1 deletion README_ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ PaddleOCR旨在打造一套丰富、领先、且实用的OCR工具库,助力
- [PP-OCR模型训练](./doc/doc_ch/training.md)
- [文本检测](./doc/doc_ch/detection.md)
- [文本识别](./doc/doc_ch/recognition.md)
- [方向分类器](./doc/doc_ch/angle_class.md)
- [文本方向分类器](./doc/doc_ch/angle_class.md)
- [配置文件内容与生成](./doc/doc_ch/config.md)
- PP-OCR模型推理部署
- [基于C++预测引擎推理](./deploy/cpp_infer/readme.md)
- [服务化部署](./deploy/pdserving/README_CN.md)
Expand Down
34 changes: 28 additions & 6 deletions deploy/cpp_infer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,32 @@
C++在性能计算上优于python,因此,在大多数CPU、GPU部署场景,多采用C++的部署方式,本节将介绍如何在Linux\Windows (CPU\GPU)环境下配置C++环境并完成
PaddleOCR模型部署。

* [1. 准备环境](#1)
+ [1.0 运行准备](#10)
+ [1.1 编译opencv库](#11)
+ [1.2 下载或者编译Paddle预测库](#12)
- [1.2.1 直接下载安装](#121)
- [1.2.2 预测库源码编译](#122)
* [2 开始运行](#2)
+ [2.1 将模型导出为inference model](#21)
+ [2.2 编译PaddleOCR C++预测demo](#22)
+ [2.3运行demo](#23)

<a name="1"></a>

## 1. 准备环境

### 运行准备
<a name="10"></a>

### 1.0 运行准备

- Linux环境,推荐使用docker。
- Windows环境,目前支持基于`Visual Studio 2019 Community`进行编译。

* 该文档主要介绍基于Linux环境的PaddleOCR C++预测流程,如果需要在Windows下基于预测库进行C++预测,具体编译方法请参考[Windows下编译教程](./docs/windows_vs2019_build.md)

<a name="11"></a>

### 1.1 编译opencv库

* 首先需要从opencv官网上下载在Linux环境下源码编译的包,以opencv3.4.7为例,下载命令如下。
Expand Down Expand Up @@ -71,6 +88,8 @@ opencv3/
|-- share
```

<a name="12"></a>

### 1.2 下载或者编译Paddle预测库

* 有2种方式获取Paddle预测库,下面进行详细介绍。
Expand Down Expand Up @@ -132,9 +151,12 @@ build/paddle_inference_install_dir/

其中`paddle`就是C++预测所需的Paddle库,`version.txt`中包含当前预测库的版本信息。

<a name="2"></a>

## 2 开始运行

<a name="21"></a>

### 2.1 将模型导出为inference model

* 可以参考[模型预测章节](../../doc/doc_ch/inference.md),导出inference model,用于模型预测。模型导出之后,假设放在`inference`目录下,则目录结构如下。
Expand All @@ -149,6 +171,7 @@ inference/
| |--inference.pdmodel
```

<a name="22"></a>

### 2.2 编译PaddleOCR C++预测demo

Expand All @@ -172,13 +195,14 @@ CUDNN_LIB_DIR=/your_cudnn_lib_dir

* 编译完成之后,会在`build`文件夹下生成一个名为`ppocr`的可执行文件。

<a name="23"></a>

### 运行demo
### 2.3 运行demo

运行方式:
```shell
./build/ppocr <mode> [--param1] [--param2] [...]
```
```
其中,`mode`为必选参数,表示选择的功能,取值范围['det', 'rec', 'system'],分别表示调用检测、识别、检测识别串联(包括方向分类器)。具体命令如下:

##### 1. 只调用检测:
Expand Down Expand Up @@ -258,6 +282,4 @@ CUDNN_LIB_DIR=/your_cudnn_lib_dir
</div>


### 2.3 注意

* 在使用Paddle预测库时,推荐使用2.0.0版本的预测库。
**注意:在使用Paddle预测库时,推荐使用2.0.0版本的预测库。**
12 changes: 6 additions & 6 deletions deploy/cpp_infer/readme_en.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Server-side C++ inference
# Server-side C++ Inference

This chapter introduces the C++ deployment method of the PaddleOCR model, and the corresponding python predictive deployment method refers to [document](../../doc/doc_ch/inference.md).
C++ is better than python in terms of performance calculation. Therefore, in most CPU and GPU deployment scenarios, C++ deployment is mostly used.
This section will introduce how to configure the C++ environment and complete it in the Linux\Windows (CPU\GPU) environment
PaddleOCR model deployment.


## 1. Prepare the environment
## 1. Prepare the Environment

### Environment

- Linux, docker is recommended.


### 1.1 Compile opencv
### 1.1 Compile OpenCV

* First of all, you need to download the source code compiled package in the Linux environment from the opencv official website. Taking opencv3.4.7 as an example, the download command is as follows.

Expand Down Expand Up @@ -73,7 +73,7 @@ opencv3/
|-- share
```

### 1.2 Compile or download or the Paddle inference library
### 1.2 Compile or Download or the Paddle Inference Library

* There are 2 ways to obtain the Paddle inference library, described in detail below.

Expand Down Expand Up @@ -136,7 +136,7 @@ build/paddle_inference_install_dir/
Among them, `paddle` is the Paddle library required for C++ prediction later, and `version.txt` contains the version information of the current inference library.


## 2. Compile and run the demo
## 2. Compile and Run the Demo

### 2.1 Export the inference model

Expand Down Expand Up @@ -183,7 +183,7 @@ or the generated Paddle inference library path (`build/paddle_inference_install_
Execute the built executable file:
```shell
./build/ppocr <mode> [--param1] [--param2] [...]
```
```
Here, `mode` is a required parameter,and the value range is ['det', 'rec', 'system'], representing using detection only, using recognition only and using the end-to-end system respectively. Specifically,

##### 1. run det demo:
Expand Down
36 changes: 24 additions & 12 deletions doc/doc_ch/add_new_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

PaddleOCR将一个算法分解为以下几个部分,并对各部分进行模块化处理,方便快速组合出新的算法。

* 数据加载和处理
* 网络
* 后处理
* 损失函数
* 指标评估
* 优化器
* [1. 数据加载和处理](#1)
* [2. 网络](#2)
* [3. 后处理](#3)
* [4. 损失函数](#4)
* [5. 指标评估](#5)
* [6. 优化器](#6)

下面将分别对每个部分进行介绍,并介绍如何在该部分里添加新算法所需模块。

## 数据加载和处理
<a name="1"></a>

## 1. 数据加载和处理

数据加载和处理由不同的模块(module)组成,其完成了图片的读取、数据增强和label的制作。这一部分在[ppocr/data](../../ppocr/data)下。 各个文件及文件夹作用说明如下:

Expand Down Expand Up @@ -64,7 +66,9 @@ transforms:
keep_keys: [ 'image', 'label' ] # dataloader will return list in this order
```

## 网络
<a name="2"></a>

## 2. 网络

网络部分完成了网络的组网操作,PaddleOCR将网络划分为四部分,这一部分在[ppocr/modeling](../../ppocr/modeling)下。 进入网络的数据将按照顺序(transforms->backbones->
necks->heads)依次通过这四个部分。
Expand Down Expand Up @@ -123,7 +127,9 @@ Architecture:
args1: args1
```

## 后处理
<a name="3"></a>

## 3. 后处理

后处理实现解码网络输出获得文本框或者识别到的文字。这一部分在[ppocr/postprocess](../../ppocr/postprocess)下。
PaddleOCR内置了DB,EAST,SAST,CRNN和Attention等算法相关的后处理模块,对于没有内置的组件可通过如下步骤添加:
Expand Down Expand Up @@ -171,7 +177,9 @@ PostProcess:
args2: args2
```

## 损失函数
<a name="4"></a>

## 4. 损失函数

损失函数用于计算网络输出和label之间的距离。这一部分在[ppocr/losses](../../ppocr/losses)下。
PaddleOCR内置了DB,EAST,SAST,CRNN和Attention等算法相关的损失函数模块,对于没有内置的模块可通过如下步骤添加:
Expand Down Expand Up @@ -208,7 +216,9 @@ Loss:
args2: args2
```

## 指标评估
<a name="5"></a>

## 5. 指标评估

指标评估用于计算网络在当前batch上的性能。这一部分在[ppocr/metrics](../../ppocr/metrics)下。 PaddleOCR内置了检测,分类和识别等算法相关的指标评估模块,对于没有内置的模块可通过如下步骤添加:

Expand Down Expand Up @@ -262,7 +272,9 @@ Metric:
main_indicator: acc
```

## 优化器
<a name="6"></a>

## 6. 优化器

优化器用于训练网络。优化器内部还包含了网络正则化和学习率衰减模块。 这一部分在[ppocr/optimizer](../../ppocr/optimizer)下。 PaddleOCR内置了`Momentum`,`Adam`
`RMSProp`等常用的优化器模块,`Linear`,`Cosine`,`Step``Piecewise`等常用的正则化模块与`L1Decay``L2Decay`等常用的学习率衰减模块。
Expand Down
29 changes: 22 additions & 7 deletions doc/doc_ch/angle_class.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
## 文字角度分类
### 方法介绍
文字角度分类主要用于图片非0度的场景下,在这种场景下需要对图片里检测到的文本行进行一个转正的操作。在PaddleOCR系统内,
# 文本方向分类器

- [1.方法介绍](#方法介绍)
- [2.数据准备](#数据准备)
- [3.启动训练](#启动训练)
- [4.训练](#训练)
- [5.评估](#评估)
- [6.预测](#预测)

<a name="方法介绍"></a>
## 1. 方法介绍
文本方向分类器主要用于图片非0度的场景下,在这种场景下需要对图片里检测到的文本行进行一个转正的操作。在PaddleOCR系统内,
文字检测之后得到的文本行图片经过仿射变换之后送入识别模型,此时只需要对文字进行一个0和180度的角度分类,因此PaddleOCR内置的
文字角度分类器**只支持了0和180度的分类**。如果想支持更多角度,可以自己修改算法进行支持。

0和180度数据样本例子:

![](../imgs_results/angle_class_example.jpg)

### 数据准备
<a name="数据准备"></a>
## 2. 数据准备

请按如下步骤设置数据集:

Expand Down Expand Up @@ -59,6 +69,8 @@ train/cls/train/word_002.jpg 180
|- word_003.jpg
| ...
```
<a name="启动训练"></a>
## 3. 启动训练

### 启动训练

Expand Down Expand Up @@ -88,7 +100,8 @@ PaddleOCR提供了多种数据增强方式,如果您希望在训练时加入

*由于OpenCV的兼容性问题,扰动操作暂时只支持linux*

### 训练
<a name="训练"></a>
## 4. 训练

PaddleOCR支持训练和评估交替进行, 可以在 `configs/cls/cls_mv3.yml` 中修改 `eval_batch_step` 设置评估频率,默认每1000个iter评估一次。训练过程中将会保存如下内容:
```bash
Expand All @@ -106,7 +119,8 @@ PaddleOCR支持训练和评估交替进行, 可以在 `configs/cls/cls_mv3.yml`

**注意,预测/评估时的配置文件请务必与训练一致。**

### 评估
<a name="评估"></a>
## 5. 评估

评估数据集可以通过修改`configs/cls/cls_mv3.yml`文件里的`Eval.dataset.label_file_list` 字段设置。

Expand All @@ -116,7 +130,8 @@ export CUDA_VISIBLE_DEVICES=0
python3 tools/eval.py -c configs/cls/cls_mv3.yml -o Global.checkpoints={path/to/weights}/best_accuracy
```

### 预测
<a name="预测"></a>
## 6. 预测

* 训练引擎的预测

Expand Down
11 changes: 10 additions & 1 deletion doc/doc_ch/config.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 配置文件内容与生成

* [1. 可选参数列表](#1)
* [2. 配置文件参数介绍](#2)
* [3. 多语言配置文件生成](#3)

<a name="1"></a>

## 1. 可选参数列表

以下列表可以通过`--help`查看
Expand All @@ -9,11 +15,12 @@
| -c | ALL | 指定配置文件 | None | **配置模块说明请参考 参数介绍** |
| -o | ALL | 设置配置文件里的参数内容 | None | 使用-o配置相较于-c选择的配置文件具有更高的优先级。例如:`-o Global.use_gpu=false` |

<a name="2"></a>

## 2. 配置文件参数介绍

`rec_chinese_lite_train_v2.0.yml ` 为例
### 2.1 Global
### Global

| 字段 | 用途 | 默认值 | 备注 |
| :----------------------: | :---------------------: | :--------------: | :--------------------: |
Expand Down Expand Up @@ -124,6 +131,8 @@
| drop_last | 是否丢弃因数据集样本数不能被 batch_size 整除而产生的最后一个不完整的mini-batch | True | \ |
| num_workers | 用于加载数据的子进程个数,若为0即为不开启子进程,在主进程中进行数据加载 | 8 | \ |

<a name="3"></a>

## 3. 多语言配置文件生成

PaddleOCR目前已支持80种(除中文外)语种识别,`configs/rec/multi_languages` 路径下提供了一个多语言的配置文件模版: [rec_multi_language_lite_train.yml](../../configs/rec/multi_language/rec_multi_language_lite_train.yml)
Expand Down
Loading

0 comments on commit 93f5b68

Please sign in to comment.