提交 2385d7ab 编写于 作者: C Channingss

update build*docs

上级 758db541
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(PaddleObjectDetector CXX C) project(PaddleX CXX C)
option(WITH_MKL "Compile demo with MKL/OpenBlas support,defaultuseMKL." ON) option(WITH_MKL "Compile demo with MKL/OpenBlas support,defaultuseMKL." ON)
option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." ON) option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." ON)
...@@ -74,7 +74,7 @@ if (WIN32) ...@@ -74,7 +74,7 @@ if (WIN32)
include_directories("${PADDLE_DIR}/paddle/include") include_directories("${PADDLE_DIR}/paddle/include")
link_directories("${PADDLE_DIR}/paddle/fluid/inference") link_directories("${PADDLE_DIR}/paddle/fluid/inference")
find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH) find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)
unset(OpenCV_DIR CACHE)
else () else ()
find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH) find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH)
include_directories("${PADDLE_DIR}/paddle/include") include_directories("${PADDLE_DIR}/paddle/include")
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
WITH_GPU=ON WITH_GPU=ON
# 是否集成 TensorRT(仅WITH_GPU=ON 有效) # 是否集成 TensorRT(仅WITH_GPU=ON 有效)
WITH_TENSORRT=OFF WITH_TENSORRT=OFF
# 上一步下载的 Paddle 预测库路径 # Paddle 预测库路径
PADDLE_DIR=/root/projects/deps/fluid_inference/ PADDLE_DIR=/path/to/fluid_inference/
# CUDA 的 lib 路径 # CUDA 的 lib 路径
CUDA_LIB=/usr/local/cuda/lib64/ CUDA_LIB=/path/to/cuda/lib/
# CUDNN 的 lib 路径 # CUDNN 的 lib 路径
CUDNN_LIB=/usr/local/cudnn/lib64/ CUDNN_LIB=/path/to/cudnn/lib/
# OPENCV 路径, 如果使用自带预编译版本可不设置 # OPENCV 路径, 如果使用自带预编译版本可不修改
OPENCV_DIR=$(pwd)/deps/opencv3gcc4.8/ OPENCV_DIR=$(pwd)/deps/opencv3gcc4.8/
sh $(pwd)/scripts/bootstrap.sh sh $(pwd)/scripts/bootstrap.sh
......
# Linux平台编译指南 # Linux平台编译指南
## 说明 ## 说明
本文档在 `Linux`平台使用`GCC 4.8.5``GCC 4.9.4`测试过,如果需要使用更高G++版本编译使用,则需要重新编译Paddle预测库,请参考: [从源码编译Paddle预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_usage/deploy/inference/build_and_install_lib_cn.html#id15) 本文档在 `Linux`平台使用`GCC 4.8.5``GCC 4.9.4`测试过,如果需要使用更高G++版本编译使用,则需要重新编译Paddle预测库,请参考: [从源码编译Paddle预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html#id12)
## 前置条件 ## 前置条件
* G++ 4.8.2 ~ 4.9.4 * G++ 4.8.2 ~ 4.9.4
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
### Step2: 下载PaddlePaddle C++ 预测库 fluid_inference ### Step2: 下载PaddlePaddle C++ 预测库 fluid_inference
PaddlePaddle C++ 预测库针对不同的`CPU``CUDA`,以及是否支持TensorRT,提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_usage/deploy/inference/build_and_install_lib_cn.html) PaddlePaddle C++ 预测库针对不同的`CPU``CUDA`,以及是否支持TensorRT,提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html#id1)
下载并解压后`/root/projects/fluid_inference`目录包含内容为: 下载并解压后`/root/projects/fluid_inference`目录包含内容为:
...@@ -32,7 +32,7 @@ fluid_inference ...@@ -32,7 +32,7 @@ fluid_inference
└── version.txt # 版本和编译信息 └── version.txt # 版本和编译信息
``` ```
**注意:** 预编译版本除`nv-jetson-cuda10-cudnn7.5-trt5` 以外其它包都是基于`GCC 4.8.5`编译,使用高版本`GCC`可能存在 `ABI`兼容性问题,建议降级或[自行编译预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html) **注意:** 预编译版本除`nv-jetson-cuda10-cudnn7.5-trt5` 以外其它包都是基于`GCC 4.8.5`编译,使用高版本`GCC`可能存在 `ABI`兼容性问题,建议降级或[自行编译预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html#id12)
### Step4: 编译 ### Step4: 编译
...@@ -74,7 +74,6 @@ make ...@@ -74,7 +74,6 @@ make
sh ./scripts/build.sh sh ./scripts/build.sh
``` ```
### Step5: 预测及可视化 ### Step5: 预测及可视化
编译成功后,预测demo的可执行程序分别为`build/detector``build/classifer``build/segmenter`,用户可根据自己的模型类型选择,其主要命令参数说明如下: 编译成功后,预测demo的可执行程序分别为`build/detector``build/classifer``build/segmenter`,用户可根据自己的模型类型选择,其主要命令参数说明如下:
...@@ -87,28 +86,31 @@ make ...@@ -87,28 +86,31 @@ make
| gpu_id | GPU 设备ID, 默认值为0 | | gpu_id | GPU 设备ID, 默认值为0 |
| save_dir | 保存可视化结果的路径, 默认值为"output",classfier无该参数 | | save_dir | 保存可视化结果的路径, 默认值为"output",classfier无该参数 |
## 样例
可使用[垃圾检测模型](deploy.md#导出inference模型)中生成的`inference_model`模型和测试图片进行预测。
`样例一` `样例一`
不使用`GPU`测试图片 `/root/projects/images/test.jpeg` 不使用`GPU`测试图片 `/path/to/garbage.bmp`
```shell ```shell
./build/detector --model_dir=/root/projects/models/yolov3_darknet --image=/root/projects/images/test.jpeg ./build/detector --model_dir=/path/to/inference_model --image=/path/to/garbage.bmp --save_dir=output
``` ```
图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。 图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。
`样例二`: `样例二`:
使用`GPU`预测多个图片`/root/projects/image_list.txt`,image_list.txt内容的格式如下: 使用`GPU`预测多个图片`/path/to/image_list.txt`,image_list.txt内容的格式如下:
``` ```
/root/projects/images/test.jpeg /path/to/images/garbage1.jpeg
/root/projects/images/test1.jpeg /path/to/images/garbage2.jpeg
... ...
/root/projects/images/testn.jpeg /path/to/images/garbagen.jpeg
``` ```
```shell ```shell
./build/detector --model_dir=/root/projects/models/yolov3_darknet --image_list=/root/projects/images_list.txt --use_gpu=1 ./build/detector --model_dir=/path/to/models/inference_model --image_list=/root/projects/images_list.txt --use_gpu=1 --save_dir=output
``` ```
图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。 图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。
# Visual Studio 2019 Community CMake 编译指南 # Visual Studio 2019 Community CMake 编译指南
## 说明
Windows 平台下,我们使用`Visual Studio 2019 Community` 进行了测试。微软从`Visual Studio 2017`开始即支持直接管理`CMake`跨平台编译项目,但是直到`2019`才提供了稳定和完全的支持,所以如果你想使用CMake管理项目编译构建,我们推荐你使用`Visual Studio 2019`环境下构建。 Windows 平台下,我们使用`Visual Studio 2019 Community` 进行了测试。微软从`Visual Studio 2017`开始即支持直接管理`CMake`跨平台编译项目,但是直到`2019`才提供了稳定和完全的支持,所以如果你想使用CMake管理项目编译构建,我们推荐你使用`Visual Studio 2019`环境下构建。
## 前置条件 ## 前置条件
* Visual Studio 2019 * Visual Studio 2019
* CUDA 9.0 / CUDA 10.0, CUDNN 7+ (仅在使用GPU版本的预测库时需要) * CUDA 9.0 / CUDA 10.0, CUDNN 7+ (仅在使用GPU版本的预测库时需要)
...@@ -16,6 +16,9 @@ Windows 平台下,我们使用`Visual Studio 2019 Community` 进行了测试 ...@@ -16,6 +16,9 @@ Windows 平台下,我们使用`Visual Studio 2019 Community` 进行了测试
下载源代码 下载源代码
```shell ```shell
d:
mkdir projects
cd projects
git clone https://github.com/PaddlePaddle/PaddleX.git git clone https://github.com/PaddlePaddle/PaddleX.git
``` ```
...@@ -26,14 +29,13 @@ git clone https://github.com/PaddlePaddle/PaddleX.git ...@@ -26,14 +29,13 @@ git clone https://github.com/PaddlePaddle/PaddleX.git
PaddlePaddle C++ 预测库针对不同的`CPU``CUDA`版本提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/windows_cpp_inference.html) PaddlePaddle C++ 预测库针对不同的`CPU``CUDA`版本提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/windows_cpp_inference.html)
解压后`D:\projects\fluid_inference`目录包含内容为: 解压后`D:\projects\fluid_inference*\`目录下主要包含的内容为:
``` ```
fluid_inference ├── \paddle\ # paddle核心库和头文件
├── paddle # paddle核心库和头文件
| |
├── third_party # 第三方依赖库和头文件 ├── \third_party\ # 第三方依赖库和头文件
| |
└── version.txt # 版本和编译信息 └── \version.txt # 版本和编译信息
``` ```
### Step3: 安装配置OpenCV ### Step3: 安装配置OpenCV
...@@ -48,36 +50,40 @@ fluid_inference ...@@ -48,36 +50,40 @@ fluid_inference
### Step4: 使用Visual Studio 2019直接编译CMake ### Step4: 使用Visual Studio 2019直接编译CMake
1. 打开Visual Studio 2019 Community,点击`继续但无需代码` 1. 打开Visual Studio 2019 Community,点击`继续但无需代码`
![step2](https://paddleseg.bj.bcebos.com/inference/vs2019_step1.png)
![step2](images/vs2019_step1.png)
2. 点击: `文件`->`打开`->`CMake` 2. 点击: `文件`->`打开`->`CMake`
![step2.1](https://paddleseg.bj.bcebos.com/inference/vs2019_step2.png)
![step2.1](images/vs2019_step2.png)
选择项目代码所在路径,并打开`CMakeList.txt`: 选择项目代码所在路径,并打开`CMakeList.txt`:
![step2.2](https://paddleseg.bj.bcebos.com/inference/vs2019_step3.png) ![step2.2](images/vs2019_step3.png)
3. 点击:`项目`->`cpp_inference_demo的CMake设置` 3. 点击:`项目`->`PADDLEX_INFERENCE的CMake设置`
![step3](https://paddleseg.bj.bcebos.com/inference/vs2019_step4.png) ![step3](images/vs2019_step4.png)
4. 点击`浏览`,分别设置编译选项指定`CUDA`、`OpenCV`、`Paddle预测库`的路径 4. 点击`浏览`,分别设置编译选项指定`CUDA`、`OpenCV`、`Paddle预测库`的路径
三个编译参数的含义说明如下(带*表示仅在使用**GPU版本**预测库时指定, 其中CUDA库版本尽量对齐,**使用9.0、10.0版本,不使用9.2、10.1等版本CUDA库**): 依赖库路径的含义说明如下(带*表示仅在使用**GPU版本**预测库时指定, 其中CUDA库版本尽量对齐,**使用9.0、10.0版本,不使用9.2、10.1等版本CUDA库**):
| 参数名 | 含义 | | 参数名 | 含义 |
| ---- | ---- | | ---- | ---- |
| *CUDA_LIB | CUDA的库路径 | | *CUDA_LIB | CUDA的库路径, 注:请将CUDNN的cudnn.lib文件拷贝到CUDA_LIB路径下 |
| OPENCV_DIR | OpenCV的安装路径, | | OPENCV_DIR | OpenCV的安装路径, |
| PADDLE_DIR | Paddle预测库的路径 | | PADDLE_DIR | Paddle c++预测库的路径 |
**注意:** 1. 使用`CPU`版预测库,请把`WITH_GPU`的勾去掉 2. 如果使用的是`openblas`版本,请把`WITH_MKL`勾去掉 **注意:** 1. 使用`CPU`版预测库,请把`WITH_GPU`的``去掉勾 2. 如果使用的是`openblas`版本,请把`WITH_MKL`的``去掉勾
![step4](https://paddleseg.bj.bcebos.com/inference/vs2019_step5.png)
![step4](images/vs2019_step5.png)
**设置完成后**, 点击上图中`保存并生成CMake缓存以加载变量`。 **设置完成后**, 点击上图中`保存并生成CMake缓存以加载变量`。
5. 点击`生成`->`全部生成` 5. 点击`生成`->`全部生成`
![step6](https://paddleseg.bj.bcebos.com/inference/vs2019_step6.png) ![step6](images/vs2019_step6.png)
### Step5: 预测及可视化 ### Step5: 预测及可视化
...@@ -85,7 +91,8 @@ fluid_inference ...@@ -85,7 +91,8 @@ fluid_inference
上述`Visual Studio 2019`编译产出的可执行文件在`out\build\x64-Release`目录下,打开`cmd`,并切换到该目录: 上述`Visual Studio 2019`编译产出的可执行文件在`out\build\x64-Release`目录下,打开`cmd`,并切换到该目录:
``` ```
cd D:\projects\PaddleX\inference\out\build\x64-Release d:
cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release
``` ```
编译成功后,预测demo的入口程序为`detector`,`classifer`,`segmenter`,用户可根据自己的模型类型选择,其主要命令参数说明如下: 编译成功后,预测demo的入口程序为`detector`,`classifer`,`segmenter`,用户可根据自己的模型类型选择,其主要命令参数说明如下:
...@@ -100,12 +107,16 @@ cd D:\projects\PaddleX\inference\out\build\x64-Release ...@@ -100,12 +107,16 @@ cd D:\projects\PaddleX\inference\out\build\x64-Release
| save_dir | 保存可视化结果的路径, 默认值为"output",classfier无该参数 | | save_dir | 保存可视化结果的路径, 默认值为"output",classfier无该参数 |
## 样例
可使用[垃圾检测模型](deploy.md#导出inference模型)中生成的`inference_model`模型和测试图片进行预测。
`样例一`: `样例一`:
不使用`GPU`测试图片 `D:\\images\\test.jpeg` 不使用`GPU`测试图片 `\\path\\to\\garbage.bmp`
```shell ```shell
.\detector --model_dir=D:\\models\\yolov3_darknet --image=D:\\images\\test.jpeg .\detector --model_dir=\\path\\to\\inference_model --image=D:\\images\\garbage.bmp --save_dir=output
``` ```
图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。 图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。
...@@ -113,15 +124,15 @@ cd D:\projects\PaddleX\inference\out\build\x64-Release ...@@ -113,15 +124,15 @@ cd D:\projects\PaddleX\inference\out\build\x64-Release
`样例二`: `样例二`:
使用`GPU`预测多个图片`D:\\images\\image_list.txt`,image_list.txt内容的格式如下: 使用`GPU`预测多个图片`\\path\\to\\image_list.txt`,image_list.txt内容的格式如下:
``` ```
D:\\images\\test.jpeg \\path\\to\\images\\garbage1.jpeg
D:\\images\\test1.jpeg \\path\\to\\images\\garbage2.jpeg
... ...
D:\\images\\testn.jpeg \\path\\to\\images\\garbagen.jpeg
``` ```
```shell ```shell
.\detector --model_dir=D:\\models\\yolov3_darknet --image_list=D:\\images\\images_list.txt --use_gpu=1 .\detector --model_dir=\\path\\to\\inference_model --image_list=\\path\\to\\images_list.txt --use_gpu=1 --save_dir=output
``` ```
图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。 图片文件`可视化预测结果`会保存在`save_dir`参数设置的目录下。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册