提交 83772e27 编写于 作者: D dongshuilong 提交者: Tingquan Gao

fix en doc bugs

上级 01d8da09
......@@ -2,12 +2,28 @@
本教程将介绍在服务器端部署PP-ShiTU的详细步骤。
## 目录
- [1.准备环境](#1)
- [1.1 升级cmake](#1.1)
- [1.2 编译opencv库](#1.2)
- [1.3 下载或者编译Paddle预测库](#1.3)
- [1.3.1 预测库源码编译](#1.3.1)
- [1.3.2 直接下载安装](#1.3.2)
- [1.4 安装faiss库](#1.4)
- [2.代码编译](#2)
- [3.运行demo](#3)
- [4.使用自己模型](#4)
<a name="1"></a>
## 1. 准备环境
### 运行准备
- Linux环境,推荐使用ubuntu docker。
<a name="1.1"></a>
### 1.1 升级cmake
由于依赖库编译需要较高版本的cmake,因此,第一步首先将cmake升级。
......@@ -48,6 +64,8 @@ cmake --version
此时,cmake就可以使用了
<a name="1.2"></a>
### 1.2 编译opencv库
* 首先需要从opencv官网上下载在Linux环境下源码编译的包,以3.4.7版本为例,下载及解压缩命令如下:
......@@ -108,11 +126,16 @@ opencv3/
|-- share
```
<a name="1.3"></a>
### 1.3 下载或者编译Paddle预测库
* 有2种方式获取Paddle预测库,下面进行详细介绍。
<a name="1.3.1"></a>
#### 1.3.1 预测库源码编译
* 如果希望获取最新预测库特性,可以从Paddle github上克隆最新代码,源码编译预测库。
* 可以参考[Paddle预测库官网](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/build_and_install_lib_cn.html#id16)的说明,从github上获取Paddle代码,然后进行编译,生成最新的预测库。使用git获取代码方法如下。
......@@ -155,6 +178,8 @@ build/paddle_inference_install_dir/
其中`paddle`就是之后进行C++预测时所需的Paddle库,`version.txt`中包含当前预测库的版本信息。
<a name="1.3.2"></a>
#### 1.3.2 直接下载安装
* [Paddle预测库官网](https://paddle-inference.readthedocs.io/en/latest/user_guides/download_lib.html)上提供了不同cuda版本的Linux预测库,可以在官网查看并选择合适的预测库版本,注意必须选择`develop`版本。
......@@ -171,6 +196,8 @@ tar -xvf paddle_inference.tgz
最终会在当前的文件夹中生成`paddle_inference/`的子文件夹。
<a name="1.4"></a>
### 1.4 安装faiss库
```shell
......@@ -191,9 +218,9 @@ apt-get install libopenblas-dev
注意本教程以安装faiss cpu版本为例,安装时请参考[faiss](https://github.com/facebookresearch/faiss)官网文档,根据需求自行安装。
## 2 代码编译
<a name="2"></a>
### 2.2 编译PaddleClas C++预测demo
## 2. 代码编译
编译命令如下,其中Paddle C++预测库、opencv等其他依赖库的地址需要换成自己机器上的实际地址。同时,编译过程中需要下载编译`yaml-cpp`等C++库,请保持联网环境。
......@@ -245,7 +272,9 @@ cd ..
在执行上述命令,编译完成之后,会在当前路径下生成`build`文件夹,其中生成一个名为`pp_shitu`的可执行文件。
## 3 运行demo
<a name="3"></a>
## 3. 运行demo
- 请参考[识别快速开始文档](../../docs/zh_CN/quick_start/quick_start_recognition.md),下载好相应的 轻量级通用主体检测模型、轻量级通用识别模型及瓶装饮料测试数据并解压。
......@@ -302,7 +331,9 @@ cd ..
![](../../docs/images/quick_start/shitu_c++_result.png)
## 4 使用自己模型
<a name="4"></a>
## 4. 使用自己模型
使用自己训练的模型,可以参考[模型导出](../../docs/zh_CN/inference_deployment/export_model.md),导出`inference model`,用于模型预测。
......
......@@ -2,12 +2,29 @@
This tutorial details the steps to deploy PP-ShiTU on the server side.
## Catalogue
- [1.Prepare the Environment](#1)
- [1.1 Update cmake](#1.1)
- [1.2 Compile opencv Library](#1.2)
- [1.3 Download or Compile Paddle Inference Library](#1.3)
- [1.3.1 Compile the Source of Inference Library](#1.3.1)
- [1.3.2 Direct Download and Installation](#1.3.2)
- [1.4 Install faiss Library](#1.4)
- [2.Code Compilation](#2)
- [3.Run the demo](#3)
- [4.Use Your Own Model](#4)
<a name="1"></a>
## 1. Prepare the Environment
### Environment Preparation
- Linux environment, ubuntu docker recommended.
<a name="1.1"></a>
### 1.1 Update cmake
The first step is to upgrade `cmake` considering the requirements of the dependency library compilation.
......@@ -48,6 +65,8 @@ cmake --version
cmake is now ready for use.
<a name="1.2"></a>
### 1.2 Compile opencv Library
- First, download the package for source compilation in Linux environment from the official website of opencv. Taking version 3.4.7 as an example, follow the command below to download and unzip it:
......@@ -108,10 +127,14 @@ opencv3/
|-- share
```
<a name="1.3"></a>
### 1.3 Download or Compile Paddle Inference Library
- Here we detail 2 ways to obtain Paddle inference library.
<a name="1.3.1"></a>
#### 1.3.1 Compile the Source of Inference Library
- To obtain the latest features of the inference library, you can clone the latest code from Paddle github and compile the source code of the library.
......@@ -155,6 +178,8 @@ build/paddle_inference_install_dir/
`paddle` is the Paddle library needed for later C++ inference, and `version.txt` contains the version information of the current inference library.
<a name="1.3.2"></a>
#### 1.3.2 Direct Download and Installation
- The Linux inference library of different cuda versions are available on the official website of [Paddle Inference Library ](https://paddle-inference.readthedocs.io/en/latest/user_guides/download_lib.html), where you can choose the appropriate version. Note that you must select the `develop` version.
......@@ -169,6 +194,8 @@ tar -xvf paddle_inference.tgz
The subfolder `paddle_inference/` will finally be created in the current folder.
<a name="1.4"></a>
### 1.4 Install faiss Library
```shell
......@@ -189,9 +216,9 @@ apt-get install libopenblas-dev
Note that this tutorial installs the cpu version of faiss as an example, please install it as your need by referring to the official documents of [faiss](https://github.com/facebookresearch/faiss).
## 2 Code Compilation
<a name="2"></a>
### 2.2 Compile the C++ Inference Demo of PP-ShiTu
## 2. Code Compilation
The command is as follows, where the address of Paddle C++ inference library, opencv and other dependency libraries need to be replaced with the actual address on your own machine. Also, you need to download and compile `yaml-cpp` and other C++ libraries during the compilation, so please keep the network unblocked.
......@@ -241,7 +268,9 @@ In the above commands:
A `build` folder will be created in the current path after the compilation, which generates an executable file named `pp_shitu`.
## 3 Run the demo
<a name="3"></a>
## 3. Run the demo
- Please refer to the [Quick Start of Recognition](../../docs/en/quick_start/quick_start_recognition_en.md), download the corresponding Lightweight Generic Mainbody Detection Model, Lightweight Generic Recognition Model, and the beverage test data and unzip them.
......@@ -298,7 +327,9 @@ A `build` folder will be created in the current path after the compilation, whic
[![img](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/quick_start/shitu_c++_result.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/quick_start/shitu_c++_result.png)
## 4 Use Your Own Model
<a name="4"></a>
## 4. Use Your Own Model
You can also use your self-trained models. Please refer to [model export](../../docs/en/inference_deployment/export_model_en.md) to export ` inference model` for model inference.
......
......@@ -9,8 +9,8 @@ See [PaddeSlim](https://github.com/PaddlePaddle/PaddleSlim/) for detailed parame
## Catlogue
- [1. PACT](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/algorithm_introduction/model_prune_quantization.md#1)
- [2. FPGM](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/algorithm_introduction/model_prune_quantization.md#2)
- [1. PACT](#1)
- [2. FPGM](#2)
<a name='1'></a>
......@@ -20,15 +20,15 @@ The model quantization comprises two main parts, the quantization of the Weight
**PACT (PArameterized Clipping acTivation)** is a new quantization method that minimizes the loss of accuracy, or even achieves great accuracy by removing some outliers before the quantization of activation. The method was proposed when the author found that "the quantized activation differed significantly from the full accuracy results when the weight quantization is adopted". The author also found that the quantization of activation can cause a great error (as a result of RELU, the range of activation is infinite compared to the weight which is basically within 0 to 1), so the activation function **clipped RELU** was introduced. The clipping ceiling, i.e., $α$, is a learnable parameter, which ensures that each layer can learn a different quantization range through training and minimizes the rounding error caused by quantization. The schematic diagram of quantization is shown below. **PACT** solves the problem by continuously trimming the activation range so that the activation distribution is narrowed, thus reducing the quantization mapping loss. It can acquire a more reasonable quantization scale and cut the quantization loss by clipping the activation, thus reducing the outliers in the activation distribution.
[![img](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/algorithm_introduction/quantization.jpg)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization.jpg)
[![img](../../images/algorithm_introduction/quantization.jpg)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization.jpg)
The quantization formula of **PACT** is as follows:
[![img](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/algorithm_introduction/quantization_formula.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization_formula.png)
[![img](../../images/algorithm_introduction/quantization_formula.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization_formula.png)
It is shown that PACT is about adopting the above quantization as a substitute for the *ReLU* function to clip the part greater than zero with a threshold of $a$. However, the above formula is further improved in *PaddleSlim* as follows:
[![img](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/algorithm_introduction/quantization_formula_slim.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization_formula_slim.png)
[![img](../../images/algorithm_introduction/quantization_formula_slim.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/quantization_formula_slim.png)
......@@ -47,6 +47,6 @@ Model pruning is an essential practice to reduce the model size and improve infe
Based on this, **FPGM** takes advantage of the geometric center property of the filter. Since filters near the center can be expressed by others, they can be eliminated, thus avoiding the above two pruning conditions. As a result, the pruning is conducted in consideration of the redundancy of information instead of a small norm. The following figure shows how the **FPGM** differs from the previous method, see [paper](https://openaccess.thecvf.com/content_CVPR_2019/papers/He_Filter_Pruning_via_Geometric_Median_) for more details.
[![img](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/algorithm_introduction/fpgm.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/fpgm.png)
[![img](../../images/algorithm_introduction/fpgm.png)](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/algorithm_introduction/fpgm.png)
For specific algorithm parameters, please refer to [Introduction to Parameters](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/pruners/fpgm_filter_pruner.rst#fpgmfilterpruner) in PaddleSlim.
......@@ -13,6 +13,7 @@
* [2. FPGM 裁剪](#2)
<a name='1'></a>
## 1. PACT 量化方法
模型量化主要包括两个部分,一是对权重 Weight 量化,一是针对激活值 Activation 量化。同时对两部分进行量化,才能获得最大的计算效率收益。权重可以借助网络正则化等手段,让权重分布尽量紧凑,减少离群点、不均匀分布情况发生,而对于激活值还缺乏有效的手段。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册