In this tutorial, we will introduce the detailed steps of deploying PaddleClas models on the server side.
Visual Studio 2019 Community
is supported. In addition, you can refer to How to use PaddleDetection to make a complete project to compile by generating the sln solution
.wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz
tar -xf 3.4.7.tar.gz
Finally, you can see the folder of opencv-3.4.7/
in the current directory.
root_path
) and installation path (install_path
) should be set by yourself. Among them, root_path
is the downloaded opencv source code path, and install_path
is the installation path of opencv. In this case, the opencv source is ./opencv-3.4.7
.cd ./opencv-3.4.7
export root_path=$PWD
export install_path=${root_path}/opencv3
rm -rf build
mkdir build
cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=${install_path} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_IPP=OFF \
-DBUILD_IPP_IW=OFF \
-DWITH_LAPACK=OFF \
-DWITH_EIGEN=OFF \
-DCMAKE_INSTALL_LIBDIR=lib64 \
-DWITH_ZLIB=ON \
-DBUILD_ZLIB=ON \
-DWITH_JPEG=ON \
-DBUILD_JPEG=ON \
-DWITH_PNG=ON \
-DBUILD_PNG=ON \
-DWITH_TIFF=ON \
-DBUILD_TIFF=ON
make -j
make install
make install
is completed, the opencv header file and library file will be generated in this folder for later PaddleClas source code compilation.Take opencv3.4.7 for example, the final file structure under the opencv installation path is as follows. NOTICE:The following file structure may be different for different Versions of Opencv.
opencv3/
|-- bin
|-- include
|-- lib64
|-- share
git clone https://github.com/PaddlePaddle/Paddle.git
rm -rf build
mkdir build
cd build
cmake .. \
-DWITH_CONTRIB=OFF \
-DWITH_MKL=ON \
-DWITH_MKLDNN=ON \
-DWITH_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_INFERENCE_API_TEST=OFF \
-DON_INFER=ON \
-DWITH_PYTHON=ON
make -j
make inference_lib_dist
For more compilation parameter options, please refer to the official website of the Paddle C++ inference library:https://www.paddlepaddle.org.cn/documentation/docs/en/develop/guides/05_inference_deployment/inference/build_and_install_lib_en.html#build-from-source-code.
build/paddle_inference_install_dir/
.build/paddle_inference_install_dir/
|-- CMakeCache.txt
|-- paddle
|-- third_party
|-- version.txt
Among them, paddle
is the Paddle library required for C++ prediction later, and version.txt
contains the version information of the current inference library.
Different cuda versions of the Linux inference library (based on GCC 4.8.2) are provided on the Paddle Inference Library official website. You can view and select the appropriate version of the inference library on the official website.
Please select the develop
version.
After downloading, use the following method to uncompress.
tar -xf paddle_inference.tgz
Finally you can see the following files in the folder of paddle_inference/
.
inference
directory, the directory structure is as follows.inference/
|--cls_infer.pdmodel
|--cls_infer.pdiparams
NOTICE: Among them, cls_infer.pdmodel
file stores the model structure information and the cls_infer.pdiparams
file stores the model parameter information.The paths of the two files need to correspond to the parameters of cls_model_path
and cls_params_path
in the configuration file tools/config.txt
.
sh tools/build.sh
Specifically, the content in tools/build.sh
is as follows.
OPENCV_DIR=your_opencv_dir
LIB_DIR=your_paddle_inference_dir
CUDA_LIB_DIR=your_cuda_lib_dir
CUDNN_LIB_DIR=your_cudnn_lib_dir
TENSORRT_DIR=your_tensorrt_lib_dir
BUILD_DIR=build
rm -rf ${BUILD_DIR}
mkdir ${BUILD_DIR}
cd ${BUILD_DIR}
cmake .. \
-DPADDLE_LIB=${LIB_DIR} \
-DWITH_MKL=ON \
-DDEMO_NAME=clas_system \
-DWITH_GPU=OFF \
-DWITH_STATIC_LIB=OFF \
-DWITH_TENSORRT=OFF \
-DTENSORRT_DIR=${TENSORRT_DIR} \
-DOPENCV_DIR=${OPENCV_DIR} \
-DCUDNN_LIB=${CUDNN_LIB_DIR} \
-DCUDA_LIB=${CUDA_LIB_DIR} \
make -j
In the above parameters of command:
OPENCV_DIR
is the opencv installation path;
LIB_DIR
is the download (paddle_inference
folder) or the generated Paddle Inference Library path (build/paddle_inference_install_dir
folder);
CUDA_LIB_DIR
is the cuda library file path, in docker; it is /usr/local/cuda/lib64
;
CUDNN_LIB_DIR
is the cudnn library file path, in docker it is /usr/lib/x86_64-linux-gnu/
.
TENSORRT_DIR
is the tensorrt library file path,in dokcer it is /usr/local/TensorRT6-cuda10.0-cudnn7/
,TensorRT is just enabled for GPU.
After the compilation is completed, an executable file named clas_system
will be generated in the build
folder.
First, please modify the tools/config.txt
and tools/run.sh
.
Some key words in tools/config.txt
is as follows.
Then execute the following command to complete the classification of an image.
sh tools/run.sh
class id
represents the id corresponding to the category with the highest confidence, and score
represents the probability that the image belongs to that category.Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )