mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[Other] Change all XPU to KunlunXin (#973)
* [FlyCV] Bump up FlyCV -> official release 1.0.0 * XPU to KunlunXin * update * update model link * update doc * update device * update code * useless code Co-authored-by: DefTruth <qiustudent_r@163.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
@@ -66,7 +66,7 @@ option(ENABLE_TEXT "Whether to enable text models usage." OFF)
|
|||||||
option(ENABLE_FLYCV "Whether to enable flycv to boost image preprocess." OFF)
|
option(ENABLE_FLYCV "Whether to enable flycv to boost image preprocess." OFF)
|
||||||
option(WITH_ASCEND "Whether to compile for Huawei Ascend deploy." OFF)
|
option(WITH_ASCEND "Whether to compile for Huawei Ascend deploy." OFF)
|
||||||
option(WITH_TIMVX "Whether to compile for TIMVX deploy." OFF)
|
option(WITH_TIMVX "Whether to compile for TIMVX deploy." OFF)
|
||||||
option(WITH_XPU "Whether to compile for KunlunXin XPU deploy." OFF)
|
option(WITH_KUNLUNXIN "Whether to compile for KunlunXin XPU deploy." OFF)
|
||||||
option(WITH_TESTING "Whether to compile with unittest." OFF)
|
option(WITH_TESTING "Whether to compile with unittest." OFF)
|
||||||
############################# Options for Android cross compiling #########################
|
############################# Options for Android cross compiling #########################
|
||||||
option(WITH_OPENCV_STATIC "Use OpenCV static lib for Android." OFF)
|
option(WITH_OPENCV_STATIC "Use OpenCV static lib for Android." OFF)
|
||||||
@@ -148,12 +148,12 @@ if (WITH_ASCEND)
|
|||||||
include(${PROJECT_SOURCE_DIR}/cmake/ascend.cmake)
|
include(${PROJECT_SOURCE_DIR}/cmake/ascend.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_XPU)
|
if (WITH_KUNLUNXIN)
|
||||||
if(NOT ENABLE_LITE_BACKEND)
|
if(NOT ENABLE_LITE_BACKEND)
|
||||||
set(ENABLE_LITE_BACKEND ON)
|
set(ENABLE_LITE_BACKEND ON)
|
||||||
endif()
|
endif()
|
||||||
if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
|
if(NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
|
||||||
message(FATAL_ERROR "XPU is only supported on Linux x64 platform")
|
message(FATAL_ERROR "KunlunXin XPU is only supported on Linux x64 platform")
|
||||||
endif()
|
endif()
|
||||||
if(NOT PADDLELITE_URL)
|
if(NOT PADDLELITE_URL)
|
||||||
set(PADDLELITE_URL "https://bj.bcebos.com/fastdeploy/third_libs/lite-linux-x64-xpu-20221215.tgz")
|
set(PADDLELITE_URL "https://bj.bcebos.com/fastdeploy/third_libs/lite-linux-x64-xpu-20221215.tgz")
|
||||||
|
@@ -27,7 +27,7 @@ set(OPENCV_DIRECTORY "@OPENCV_DIRECTORY@")
|
|||||||
set(ORT_DIRECTORY "@ORT_DIRECTORY@")
|
set(ORT_DIRECTORY "@ORT_DIRECTORY@")
|
||||||
set(OPENVINO_DIRECTORY "@OPENVINO_DIRECTORY@")
|
set(OPENVINO_DIRECTORY "@OPENVINO_DIRECTORY@")
|
||||||
set(RKNN2_TARGET_SOC "@RKNN2_TARGET_SOC@")
|
set(RKNN2_TARGET_SOC "@RKNN2_TARGET_SOC@")
|
||||||
set(WITH_XPU @WITH_XPU@)
|
set(WITH_KUNLUNXIN @WITH_KUNLUNXIN@)
|
||||||
|
|
||||||
set(FASTDEPLOY_LIBS "")
|
set(FASTDEPLOY_LIBS "")
|
||||||
set(FASTDEPLOY_INCS "")
|
set(FASTDEPLOY_INCS "")
|
||||||
@@ -246,7 +246,7 @@ if(ENABLE_PADDLE_FRONTEND)
|
|||||||
list(APPEND FASTDEPLOY_LIBS ${PADDLE2ONNX_LIB})
|
list(APPEND FASTDEPLOY_LIBS ${PADDLE2ONNX_LIB})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_XPU)
|
if(WITH_KUNLUNXIN)
|
||||||
list(APPEND FASTDEPLOY_LIBS -lpthread -lrt -ldl)
|
list(APPEND FASTDEPLOY_LIBS -lpthread -lrt -ldl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ function(fastdeploy_summary)
|
|||||||
message(STATUS " ENABLE_OPENVINO_BACKEND : ${ENABLE_OPENVINO_BACKEND}")
|
message(STATUS " ENABLE_OPENVINO_BACKEND : ${ENABLE_OPENVINO_BACKEND}")
|
||||||
message(STATUS " WITH_ASCEND : ${WITH_ASCEND}")
|
message(STATUS " WITH_ASCEND : ${WITH_ASCEND}")
|
||||||
message(STATUS " WITH_TIMVX : ${WITH_TIMVX}")
|
message(STATUS " WITH_TIMVX : ${WITH_TIMVX}")
|
||||||
message(STATUS " WITH_XPU : ${WITH_XPU}")
|
message(STATUS " WITH_KUNLUNXIN : ${WITH_KUNLUNXIN}")
|
||||||
if(ENABLE_ORT_BACKEND)
|
if(ENABLE_ORT_BACKEND)
|
||||||
message(STATUS " ONNXRuntime version : ${ONNXRUNTIME_VERSION}")
|
message(STATUS " ONNXRuntime version : ${ONNXRUNTIME_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
- [Build and Install FastDeploy Library on GPU Platform](en/build_and_install/gpu.md)
|
- [Build and Install FastDeploy Library on GPU Platform](en/build_and_install/gpu.md)
|
||||||
- [Build and Install FastDeploy Library on CPU Platform](en/build_and_install/cpu.md)
|
- [Build and Install FastDeploy Library on CPU Platform](en/build_and_install/cpu.md)
|
||||||
- [Build and Install FastDeploy Library on IPU Platform](en/build_and_install/ipu.md)
|
- [Build and Install FastDeploy Library on IPU Platform](en/build_and_install/ipu.md)
|
||||||
- [Build and Install FastDeploy Library on KunlunXin XPU Platform](en/build_and_install/xpu.md)
|
- [Build and Install FastDeploy Library on KunlunXin XPU Platform](en/build_and_install/kunlunxin.md)
|
||||||
- [Build and Install on RV1126 Platform](en/build_and_install/rv1126.md)
|
- [Build and Install on RV1126 Platform](en/build_and_install/rv1126.md)
|
||||||
- [Build and Install on RK3588 and RK356X Platform](en/build_and_install/rknpu2.md)
|
- [Build and Install on RK3588 and RK356X Platform](en/build_and_install/rknpu2.md)
|
||||||
- [Build and Install on A311D Platform](en/build_and_install/a311d.md)
|
- [Build and Install on A311D Platform](en/build_and_install/a311d.md)
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
- [GPU部署环境编译安装](cn/build_and_install/gpu.md)
|
- [GPU部署环境编译安装](cn/build_and_install/gpu.md)
|
||||||
- [CPU部署环境编译安装](cn/build_and_install/cpu.md)
|
- [CPU部署环境编译安装](cn/build_and_install/cpu.md)
|
||||||
- [IPU部署环境编译安装](cn/build_and_install/ipu.md)
|
- [IPU部署环境编译安装](cn/build_and_install/ipu.md)
|
||||||
- [昆仑芯XPU部署环境编译安装](cn/build_and_install/xpu.md)
|
- [昆仑芯XPU部署环境编译安装](cn/build_and_install/kunlunxin.md)
|
||||||
- [瑞芯微RV1126部署环境编译安装](cn/build_and_install/rv1126.md)
|
- [瑞芯微RV1126部署环境编译安装](cn/build_and_install/rv1126.md)
|
||||||
- [瑞芯微RK3588部署环境编译安装](cn/build_and_install/rknpu2.md)
|
- [瑞芯微RK3588部署环境编译安装](cn/build_and_install/rknpu2.md)
|
||||||
- [晶晨A311D部署环境编译安装](cn/build_and_install/a311d.md)
|
- [晶晨A311D部署环境编译安装](cn/build_and_install/a311d.md)
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
- [Build and Install FastDeploy Library on GPU Platform](en/build_and_install/gpu.md)
|
- [Build and Install FastDeploy Library on GPU Platform](en/build_and_install/gpu.md)
|
||||||
- [Build and Install FastDeploy Library on CPU Platform](en/build_and_install/cpu.md)
|
- [Build and Install FastDeploy Library on CPU Platform](en/build_and_install/cpu.md)
|
||||||
- [Build and Install FastDeploy Library on IPU Platform](en/build_and_install/ipu.md)
|
- [Build and Install FastDeploy Library on IPU Platform](en/build_and_install/ipu.md)
|
||||||
- [Build and Install FastDeploy Library on KunlunXin XPU Platform](en/build_and_install/xpu.md)
|
- [Build and Install FastDeploy Library on KunlunXin XPU Platform](en/build_and_install/kunlunxin.md)
|
||||||
- [Build and Install on RV1126 Platform](en/build_and_install/rv1126.md)
|
- [Build and Install on RV1126 Platform](en/build_and_install/rv1126.md)
|
||||||
- [Build and Install on RK3588 Platform](en/build_and_install/rknpu2.md)
|
- [Build and Install on RK3588 Platform](en/build_and_install/rknpu2.md)
|
||||||
- [Build and Install on A311D Platform](en/build_and_install/a311d.md)
|
- [Build and Install on A311D Platform](en/build_and_install/a311d.md)
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
- [瑞芯微RV1126部署环境](rv1126.md)
|
- [瑞芯微RV1126部署环境](rv1126.md)
|
||||||
- [瑞芯微RK3588部署环境](rknpu2.md)
|
- [瑞芯微RK3588部署环境](rknpu2.md)
|
||||||
- [晶晨A311D部署环境](a311d.md)
|
- [晶晨A311D部署环境](a311d.md)
|
||||||
- [昆仑芯XPU部署环境](xpu.md)
|
- [昆仑芯XPU部署环境](kunlunxin.md)
|
||||||
- [华为昇腾部署环境](huawei_ascend.md)
|
- [华为昇腾部署环境](huawei_ascend.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
| ENABLE_LITE_BACKEND | 默认OFF,是否编译集成Paddle Lite后端(编译Android库时需要设置为ON) |
|
| ENABLE_LITE_BACKEND | 默认OFF,是否编译集成Paddle Lite后端(编译Android库时需要设置为ON) |
|
||||||
| ENABLE_RKNPU2_BACKEND | 默认OFF,是否编译集成RKNPU2后端(RK3588/RK3568/RK3566上推荐打开) |
|
| ENABLE_RKNPU2_BACKEND | 默认OFF,是否编译集成RKNPU2后端(RK3588/RK3568/RK3566上推荐打开) |
|
||||||
| WITH_ASCEND | 默认OFF,当在华为昇腾NPU上部署时, 需要设置为ON |
|
| WITH_ASCEND | 默认OFF,当在华为昇腾NPU上部署时, 需要设置为ON |
|
||||||
| WITH_XPU | 默认OFF,当在昆仑芯XPU上部署时,需设置为ON |
|
| WITH_KUNLUNXIN | 默认OFF,当在昆仑芯XPU上部署时,需设置为ON |
|
||||||
| WITH_TIMVX | 默认OFF,需要在RV1126/RV1109/A311D上部署时,需设置为ON |
|
| WITH_TIMVX | 默认OFF,需要在RV1126/RV1109/A311D上部署时,需设置为ON |
|
||||||
| ENABLE_TRT_BACKEND | 默认OFF,是否编译集成TensorRT后端(GPU上推荐打开) |
|
| ENABLE_TRT_BACKEND | 默认OFF,是否编译集成TensorRT后端(GPU上推荐打开) |
|
||||||
| ENABLE_OPENVINO_BACKEND | 默认OFF,是否编译集成OpenVINO后端(CPU上推荐打开) |
|
| ENABLE_OPENVINO_BACKEND | 默认OFF,是否编译集成OpenVINO后端(CPU上推荐打开) |
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
[English](../../en/build_and_install/xpu.md) | 简体中文
|
[English](../../en/build_and_install/kunlunxin.md) | 简体中文
|
||||||
|
|
||||||
# 昆仑芯 XPU 部署环境编译安装
|
# 昆仑芯 XPU 部署环境编译安装
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ FastDeploy 基于 Paddle Lite 后端支持在昆仑芯 XPU 上进行部署推理
|
|||||||
相关编译选项说明如下:
|
相关编译选项说明如下:
|
||||||
|编译选项|默认值|说明|备注|
|
|编译选项|默认值|说明|备注|
|
||||||
|:---|:---|:---|:---|
|
|:---|:---|:---|:---|
|
||||||
| WITH_XPU| OFF | 需要在XPU上部署时需要设置为ON | - |
|
| WITH_KUNLUNXIN| OFF | 需要在昆仑芯XPU上部署时需要设置为ON | - |
|
||||||
| ENABLE_ORT_BACKEND | OFF | 是否编译集成ONNX Runtime后端 | - |
|
| ENABLE_ORT_BACKEND | OFF | 是否编译集成ONNX Runtime后端 | - |
|
||||||
| ENABLE_PADDLE_BACKEND | OFF | 是否编译集成Paddle Inference后端 | - |
|
| ENABLE_PADDLE_BACKEND | OFF | 是否编译集成Paddle Inference后端 | - |
|
||||||
| ENABLE_OPENVINO_BACKEND | OFF | 是否编译集成OpenVINO后端 | - |
|
| ENABLE_OPENVINO_BACKEND | OFF | 是否编译集成OpenVINO后端 | - |
|
||||||
@@ -41,11 +41,11 @@ cd FastDeploy
|
|||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
|
||||||
# CMake configuration with KunlunXin xpu toolchain
|
# CMake configuration with KunlunXin xpu toolchain
|
||||||
cmake -DWITH_XPU=ON \
|
cmake -DWITH_KUNLUNXIN=ON \
|
||||||
-DWITH_GPU=OFF \ # 不编译 GPU
|
-DWITH_GPU=OFF \ # 不编译 GPU
|
||||||
-DENABLE_ORT_BACKEND=ON \ # 可选择开启 ORT 后端
|
-DENABLE_ORT_BACKEND=ON \ # 可选择开启 ORT 后端
|
||||||
-DENABLE_PADDLE_BACKEND=ON \ # 可选择开启 Paddle 后端
|
-DENABLE_PADDLE_BACKEND=ON \ # 可选择开启 Paddle 后端
|
||||||
-DCMAKE_INSTALL_PREFIX=fastdeploy-xpu \
|
-DCMAKE_INSTALL_PREFIX=fastdeploy-kunlunxin \
|
||||||
-DENABLE_VISION=ON \ # 是否编译集成视觉模型的部署模块,可选择开启
|
-DENABLE_VISION=ON \ # 是否编译集成视觉模型的部署模块,可选择开启
|
||||||
-DOPENCV_DIRECTORY=/usr/lib/x86_64-linux-gnu/cmake/opencv4 \
|
-DOPENCV_DIRECTORY=/usr/lib/x86_64-linux-gnu/cmake/opencv4 \
|
||||||
..
|
..
|
||||||
@@ -54,14 +54,14 @@ cmake -DWITH_XPU=ON \
|
|||||||
make -j8
|
make -j8
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
编译完成之后,会生成 fastdeploy-xpu 目录,表示基于 Paddle Lite 的 FastDeploy 库编译完成。
|
编译完成之后,会生成 fastdeploy-kunlunxin 目录,表示基于 Paddle Lite 的 FastDeploy 库编译完成。
|
||||||
|
|
||||||
## Python 编译
|
## Python 编译
|
||||||
编译命令如下:
|
编译命令如下:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export WITH_XPU=ON
|
export WITH_KUNLUNXIN=ON
|
||||||
export WITH_GPU=OFF
|
export WITH_GPU=OFF
|
||||||
export ENABLE_ORT_BACKEND=ON
|
export ENABLE_ORT_BACKEND=ON
|
||||||
export ENABLE_PADDLE_BACKEND=ON
|
export ENABLE_PADDLE_BACKEND=ON
|
@@ -15,7 +15,7 @@ English | [中文](../../cn/build_and_install/README.md)
|
|||||||
- [Build and Install on RV1126 Platform](rv1126.md)
|
- [Build and Install on RV1126 Platform](rv1126.md)
|
||||||
- [Build and Install on RK3588 Platform](rknpu2.md)
|
- [Build and Install on RK3588 Platform](rknpu2.md)
|
||||||
- [Build and Install on A311D Platform](a311d.md)
|
- [Build and Install on A311D Platform](a311d.md)
|
||||||
- [Build and Install on KunlunXin XPU Platform](xpu.md)
|
- [Build and Install on KunlunXin XPU Platform](kunlunxin.md)
|
||||||
|
|
||||||
|
|
||||||
## Build options
|
## Build options
|
||||||
@@ -29,7 +29,7 @@ English | [中文](../../cn/build_and_install/README.md)
|
|||||||
| ENABLE_VISION | Default OFF,whether to enable vision models deployment module |
|
| ENABLE_VISION | Default OFF,whether to enable vision models deployment module |
|
||||||
| ENABLE_TEXT | Default OFF,whether to enable text models deployment module |
|
| ENABLE_TEXT | Default OFF,whether to enable text models deployment module |
|
||||||
| WITH_GPU | Default OFF, if build on GPU, this needs to be ON |
|
| WITH_GPU | Default OFF, if build on GPU, this needs to be ON |
|
||||||
| WITH_XPU | Default OFF,if deploy on KunlunXin XPU,this needs to be ON |
|
| WITH_KUNLUNXIN | Default OFF,if deploy on KunlunXin XPU,this needs to be ON |
|
||||||
| WITH_TIMVX | Default OFF,if deploy on RV1126/RV1109/A311D,this needs to be ON |
|
| WITH_TIMVX | Default OFF,if deploy on RV1126/RV1109/A311D,this needs to be ON |
|
||||||
| WITH_ASCEND | Default OFF,if deploy on Huawei Ascend,this needs to be ON |
|
| WITH_ASCEND | Default OFF,if deploy on Huawei Ascend,this needs to be ON |
|
||||||
| CUDA_DIRECTORY | Default /usr/local/cuda, if build on GPU, this defines the path of CUDA(>=11.2) |
|
| CUDA_DIRECTORY | Default /usr/local/cuda, if build on GPU, this defines the path of CUDA(>=11.2) |
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
English | [中文](../../cn/build_and_install/xpu.md)
|
English | [中文](../../cn/build_and_install/kunlunxin.md)
|
||||||
|
|
||||||
# How to Build KunlunXin XPU Deployment Environment
|
# How to Build KunlunXin XPU Deployment Environment
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ The relevant compilation options are described as follows:
|
|||||||
|Compile Options|Default Values|Description|Remarks|
|
|Compile Options|Default Values|Description|Remarks|
|
||||||
|:---|:---|:---|:---|
|
|:---|:---|:---|:---|
|
||||||
| ENABLE_LITE_BACKEND | OFF | It needs to be set to ON when compiling the RK library| - |
|
| ENABLE_LITE_BACKEND | OFF | It needs to be set to ON when compiling the RK library| - |
|
||||||
| WITH_XPU | OFF | It needs to be set to ON when compiling the KunlunXin XPU library| - |
|
| WITH_KUNLUNXIN | OFF | It needs to be set to ON when compiling the KunlunXin XPU library| - |
|
||||||
| ENABLE_ORT_BACKEND | OFF | whether to intergrate ONNX Runtime backend | - |
|
| ENABLE_ORT_BACKEND | OFF | whether to intergrate ONNX Runtime backend | - |
|
||||||
| ENABLE_PADDLE_BACKEND | OFF | whether to intergrate Paddle Inference backend | - |
|
| ENABLE_PADDLE_BACKEND | OFF | whether to intergrate Paddle Inference backend | - |
|
||||||
| ENABLE_OPENVINO_BACKEND | OFF | whether to intergrate OpenVINO backend | - |
|
| ENABLE_OPENVINO_BACKEND | OFF | whether to intergrate OpenVINO backend | - |
|
||||||
@@ -44,11 +44,11 @@ cd FastDeploy
|
|||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
|
||||||
# CMake configuration with KunlunXin xpu toolchain
|
# CMake configuration with KunlunXin xpu toolchain
|
||||||
cmake -DWITH_XPU=ON \
|
cmake -DWITH_KUNLUNXIN=ON \
|
||||||
-DWITH_GPU=OFF \
|
-DWITH_GPU=OFF \
|
||||||
-DENABLE_ORT_BACKEND=ON \
|
-DENABLE_ORT_BACKEND=ON \
|
||||||
-DENABLE_PADDLE_BACKEND=ON \
|
-DENABLE_PADDLE_BACKEND=ON \
|
||||||
-DCMAKE_INSTALL_PREFIX=fastdeploy-xpu \
|
-DCMAKE_INSTALL_PREFIX=fastdeploy-kunlunxin \
|
||||||
-DENABLE_VISION=ON \
|
-DENABLE_VISION=ON \
|
||||||
-DOPENCV_DIRECTORY=/usr/lib/x86_64-linux-gnu/cmake/opencv4 \
|
-DOPENCV_DIRECTORY=/usr/lib/x86_64-linux-gnu/cmake/opencv4 \
|
||||||
..
|
..
|
||||||
@@ -57,14 +57,14 @@ cmake -DWITH_XPU=ON \
|
|||||||
make -j8
|
make -j8
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
After the compilation is complete, the fastdeploy-xpu directory will be generated, indicating that the Padddle Lite based FastDeploy library has been compiled.
|
After the compilation is complete, the fastdeploy-kunlunxin directory will be generated, indicating that the Padddle Lite based FastDeploy library has been compiled.
|
||||||
|
|
||||||
## Python compile
|
## Python compile
|
||||||
The compilation command is as follows:
|
The compilation command is as follows:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export WITH_XPU=ON
|
export WITH_KUNLUNXIN=ON
|
||||||
export WITH_GPU=OFF
|
export WITH_GPU=OFF
|
||||||
export ENABLE_ORT_BACKEND=ON
|
export ENABLE_ORT_BACKEND=ON
|
||||||
export ENABLE_PADDLE_BACKEND=ON
|
export ENABLE_PADDLE_BACKEND=ON
|
@@ -41,7 +41,7 @@ python infer.py --model_dir stable-diffusion-v1-4/ --scheduler "pndm" --backend
|
|||||||
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle
|
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle
|
||||||
|
|
||||||
# 在昆仑芯XPU上推理
|
# 在昆仑芯XPU上推理
|
||||||
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle-xpu
|
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle-kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 参数说明
|
#### 参数说明
|
||||||
@@ -52,7 +52,7 @@ python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral"
|
|||||||
|----------|--------------|
|
|----------|--------------|
|
||||||
| --model_dir | 导出后模型的目录。 |
|
| --model_dir | 导出后模型的目录。 |
|
||||||
| --model_format | 模型格式。默认为`'paddle'`,可选列表:`['paddle', 'onnx']`。 |
|
| --model_format | 模型格式。默认为`'paddle'`,可选列表:`['paddle', 'onnx']`。 |
|
||||||
| --backend | 推理引擎后端。默认为`paddle`,可选列表:`['onnx_runtime', 'paddle', 'paddle-xpu']`,当模型格式为`onnx`时,可选列表为`['onnx_runtime']`。 |
|
| --backend | 推理引擎后端。默认为`paddle`,可选列表:`['onnx_runtime', 'paddle', 'paddle-kunlunxin']`,当模型格式为`onnx`时,可选列表为`['onnx_runtime']`。 |
|
||||||
| --scheduler | StableDiffusion 模型的scheduler。默认为`'pndm'`。可选列表:`['pndm', 'euler_ancestral']`,StableDiffusio模型对应的scheduler可参考[ppdiffuser模型列表](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/ppdiffusers/examples/textual_inversion)。|
|
| --scheduler | StableDiffusion 模型的scheduler。默认为`'pndm'`。可选列表:`['pndm', 'euler_ancestral']`,StableDiffusio模型对应的scheduler可参考[ppdiffuser模型列表](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/ppdiffusers/examples/textual_inversion)。|
|
||||||
| --unet_model_prefix | UNet模型前缀。默认为`unet`。 |
|
| --unet_model_prefix | UNet模型前缀。默认为`unet`。 |
|
||||||
| --vae_model_prefix | VAE模型前缀。默认为`vae_decoder`。 |
|
| --vae_model_prefix | VAE模型前缀。默认为`vae_decoder`。 |
|
||||||
|
@@ -69,7 +69,7 @@ def parse_arguments():
|
|||||||
type=str,
|
type=str,
|
||||||
default='paddle',
|
default='paddle',
|
||||||
# Note(zhoushunjie): Will support 'tensorrt', 'paddle-tensorrt' soon.
|
# Note(zhoushunjie): Will support 'tensorrt', 'paddle-tensorrt' soon.
|
||||||
choices=['onnx_runtime', 'paddle', 'paddle-xpu'],
|
choices=['onnx_runtime', 'paddle', 'paddle-kunlunxin'],
|
||||||
help="The inference runtime backend of unet model and text encoder model."
|
help="The inference runtime backend of unet model and text encoder model."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -175,9 +175,9 @@ def create_trt_runtime(model_dir,
|
|||||||
return fd.Runtime(option)
|
return fd.Runtime(option)
|
||||||
|
|
||||||
|
|
||||||
def create_xpu_runtime(model_dir, model_prefix, device_id=0):
|
def create_kunlunxin_runtime(model_dir, model_prefix, device_id=0):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
option.use_xpu(
|
option.use_kunlunxin(
|
||||||
device_id,
|
device_id,
|
||||||
l3_workspace_size=(64 * 1024 * 1024 - 4 * 1024),
|
l3_workspace_size=(64 * 1024 * 1024 - 4 * 1024),
|
||||||
locked=False,
|
locked=False,
|
||||||
@@ -306,18 +306,18 @@ if __name__ == "__main__":
|
|||||||
dynamic_shape=unet_dynamic_shape,
|
dynamic_shape=unet_dynamic_shape,
|
||||||
device_id=args.device_id)
|
device_id=args.device_id)
|
||||||
print(f"Spend {time.time() - start : .2f} s to load unet model.")
|
print(f"Spend {time.time() - start : .2f} s to load unet model.")
|
||||||
elif args.backend == "paddle-xpu":
|
elif args.backend == "paddle-kunlunxin":
|
||||||
print("=== build text_encoder_runtime")
|
print("=== build text_encoder_runtime")
|
||||||
text_encoder_runtime = create_xpu_runtime(
|
text_encoder_runtime = create_kunlunxin_runtime(
|
||||||
args.model_dir,
|
args.model_dir,
|
||||||
args.text_encoder_model_prefix,
|
args.text_encoder_model_prefix,
|
||||||
device_id=args.device_id)
|
device_id=args.device_id)
|
||||||
print("=== build vae_decoder_runtime")
|
print("=== build vae_decoder_runtime")
|
||||||
vae_decoder_runtime = create_xpu_runtime(
|
vae_decoder_runtime = create_kunlunxin_runtime(
|
||||||
args.model_dir, args.vae_model_prefix, device_id=args.device_id)
|
args.model_dir, args.vae_model_prefix, device_id=args.device_id)
|
||||||
print("=== build unet_runtime")
|
print("=== build unet_runtime")
|
||||||
start = time.time()
|
start = time.time()
|
||||||
unet_runtime = create_xpu_runtime(
|
unet_runtime = create_kunlunxin_runtime(
|
||||||
args.model_dir, args.unet_model_prefix, device_id=args.device_id)
|
args.model_dir, args.unet_model_prefix, device_id=args.device_id)
|
||||||
print(f"Spend {time.time() - start : .2f} s to load unet model.")
|
print(f"Spend {time.time() - start : .2f} s to load unet model.")
|
||||||
pipe = StableDiffusionFastDeployPipeline(
|
pipe = StableDiffusionFastDeployPipeline(
|
||||||
|
@@ -35,8 +35,8 @@ tar xvfz ernie-3.0-medium-zh-afqmc.tgz
|
|||||||
# GPU Inference
|
# GPU Inference
|
||||||
./seq_cls_infer_demo --device gpu --model_dir ernie-3.0-medium-zh-afqmc
|
./seq_cls_infer_demo --device gpu --model_dir ernie-3.0-medium-zh-afqmc
|
||||||
|
|
||||||
# XPU 推理
|
# KunlunXin XPU 推理
|
||||||
./seq_cls_infer_demo --device xpu --model_dir ernie-3.0-medium-zh-afqmc
|
./seq_cls_infer_demo --device kunlunxin --model_dir ernie-3.0-medium-zh-afqmc
|
||||||
```
|
```
|
||||||
The result returned after running is as follows:
|
The result returned after running is as follows:
|
||||||
```bash
|
```bash
|
||||||
|
@@ -32,7 +32,7 @@ const char sep = '/';
|
|||||||
DEFINE_string(model_dir, "", "Directory of the inference model.");
|
DEFINE_string(model_dir, "", "Directory of the inference model.");
|
||||||
DEFINE_string(vocab_path, "", "Path of the vocab file.");
|
DEFINE_string(vocab_path, "", "Path of the vocab file.");
|
||||||
DEFINE_string(device, "cpu",
|
DEFINE_string(device, "cpu",
|
||||||
"Type of inference device, support 'cpu', 'xpu' or 'gpu'.");
|
"Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.");
|
||||||
DEFINE_string(backend, "onnx_runtime",
|
DEFINE_string(backend, "onnx_runtime",
|
||||||
"The inference runtime backend, support: ['onnx_runtime', "
|
"The inference runtime backend, support: ['onnx_runtime', "
|
||||||
"'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt']");
|
"'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt']");
|
||||||
@@ -61,8 +61,8 @@ bool CreateRuntimeOption(fastdeploy::RuntimeOption* option) {
|
|||||||
<< ", param_path = " << param_path << std::endl;
|
<< ", param_path = " << param_path << std::endl;
|
||||||
option->SetModelPath(model_path, param_path);
|
option->SetModelPath(model_path, param_path);
|
||||||
|
|
||||||
if (FLAGS_device == "xpu") {
|
if (FLAGS_device == "kunlunxin") {
|
||||||
option->UseXpu();
|
option->UseKunlunXin();
|
||||||
return true;
|
return true;
|
||||||
} else if (FLAGS_device == "gpu") {
|
} else if (FLAGS_device == "gpu") {
|
||||||
option->UseGpu();
|
option->UseGpu();
|
||||||
|
@@ -40,8 +40,8 @@ python seq_cls_infer.py --device cpu --model_dir ernie-3.0-medium-zh-afqmc
|
|||||||
# GPU Inference
|
# GPU Inference
|
||||||
python seq_cls_infer.py --device gpu --model_dir ernie-3.0-medium-zh-afqmc
|
python seq_cls_infer.py --device gpu --model_dir ernie-3.0-medium-zh-afqmc
|
||||||
|
|
||||||
# XPU Inference
|
# KunlunXin XPU Inference
|
||||||
python seq_cls_infer.py --device xpu --model_dir ernie-3.0-medium-zh-afqmc
|
python seq_cls_infer.py --device kunlunxin --model_dir ernie-3.0-medium-zh-afqmc
|
||||||
|
|
||||||
```
|
```
|
||||||
The result returned after running is as follows:
|
The result returned after running is as follows:
|
||||||
|
@@ -35,8 +35,8 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
choices=['gpu', 'cpu', 'xpu'],
|
choices=['gpu', 'cpu', 'kunlunxin'],
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--backend",
|
"--backend",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -94,8 +94,8 @@ class ErnieForSequenceClassificationPredictor(object):
|
|||||||
model_path = os.path.join(args.model_dir, "infer.pdmodel")
|
model_path = os.path.join(args.model_dir, "infer.pdmodel")
|
||||||
params_path = os.path.join(args.model_dir, "infer.pdiparams")
|
params_path = os.path.join(args.model_dir, "infer.pdiparams")
|
||||||
option.set_model_path(model_path, params_path)
|
option.set_model_path(model_path, params_path)
|
||||||
if args.device == 'xpu':
|
if args.device == 'kunlunxin':
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
option.use_paddle_lite_backend()
|
option.use_paddle_lite_backend()
|
||||||
return fd.Runtime(option)
|
return fd.Runtime(option)
|
||||||
if args.device == 'cpu':
|
if args.device == 'cpu':
|
||||||
|
@@ -96,13 +96,13 @@ void IpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << res.Str() << std::endl;
|
std::cout << res.Str() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "inference.pdmodel";
|
auto model_file = model_dir + sep + "inference.pdmodel";
|
||||||
auto params_file = model_dir + sep + "inference.pdiparams";
|
auto params_file = model_dir + sep + "inference.pdiparams";
|
||||||
auto config_file = model_dir + sep + "inference_cls.yaml";
|
auto config_file = model_dir + sep + "inference_cls.yaml";
|
||||||
|
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::classification::PaddleClasModel(
|
auto model = fastdeploy::vision::classification::PaddleClasModel(
|
||||||
model_file, params_file, config_file, option);
|
model_file, params_file, config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -179,7 +179,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_demo ./ResNet50_vd ./test.jpeg 0"
|
"e.g ./infer_demo ./ResNet50_vd ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with ipu; 4: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with ipu; 4: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
IpuInfer(argv[1], argv[2]);
|
IpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 4) {
|
} else if (std::atoi(argv[3]) == 4) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 5) {
|
} else if (std::atoi(argv[3]) == 5) {
|
||||||
AscendInfer(argv[1], argv[2]);
|
AscendInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg -
|
|||||||
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device gpu --use_trt True --topk 1
|
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device gpu --use_trt True --topk 1
|
||||||
# IPU推理(注意:IPU推理首次运行会有序列化模型的操作,有一定耗时,需要耐心等待)
|
# IPU推理(注意:IPU推理首次运行会有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device ipu --topk 1
|
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device ipu --topk 1
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device xpu --topk 1
|
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device kunlunxin --topk 1
|
||||||
# 华为昇腾NPU推理
|
# 华为昇腾NPU推理
|
||||||
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device ascend --topk 1
|
python infer.py --model ResNet50_vd_infer --image ILSVRC2012_val_00000010.jpeg --device ascend --topk 1
|
||||||
```
|
```
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu' or 'gpu' or 'ipu' or 'xpu' or 'ascend' ."
|
help="Type of inference device, support 'cpu' or 'gpu' or 'ipu' or 'kunlunxin' or 'ascend' ."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
@@ -36,8 +36,8 @@ def build_option(args):
|
|||||||
if args.device.lower() == "ipu":
|
if args.device.lower() == "ipu":
|
||||||
option.use_ipu()
|
option.use_ipu()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "ascend":
|
if args.device.lower() == "ascend":
|
||||||
option.use_ascend()
|
option.use_ascend()
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu(0, 0, false, false);
|
option.UseKunlunXin(0, 0, false, false);
|
||||||
auto model = fastdeploy::vision::detection::FasterRCNN(
|
auto model = fastdeploy::vision::detection::FasterRCNN(
|
||||||
model_file, params_file, config_file, option);
|
model_file, params_file, config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -109,7 +109,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./faster_rcnn_r50_vd_fpn_2x_coco ./test.jpeg 0"
|
"e.g ./infer_model ./faster_rcnn_r50_vd_fpn_2x_coco ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu(0, 0, false, false);
|
option.UseKunlunXin(0, 0, false, false);
|
||||||
auto model = fastdeploy::vision::detection::MaskRCNN(model_file, params_file,
|
auto model = fastdeploy::vision::detection::MaskRCNN(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -109,7 +109,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./mask_rcnn_r50_1x_coco/ ./test.jpeg 0"
|
"e.g ./infer_model ./mask_rcnn_r50_1x_coco/ ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
std::cout
|
std::cout
|
||||||
<< "Backend::TRT has not been supported yet, will skip this inference."
|
<< "Backend::TRT has not been supported yet, will skip this inference."
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PicoDet(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PicoDet(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -138,7 +138,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./picodet_model_dir ./test.jpeg 0"
|
"e.g ./infer_model ./picodet_model_dir ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PPYOLO(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PPYOLO(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -109,7 +109,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PPYOLOE(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PPYOLOE(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -138,7 +138,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyoloe_model_dir ./test.jpeg 0"
|
"e.g ./infer_model ./ppyoloe_model_dir ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::RTMDet(model_file, params_file,
|
auto model = fastdeploy::vision::detection::RTMDet(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -141,7 +141,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu, 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu, 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if(std::atoi(argv[3]) == 2) {
|
} else if(std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if(std::atoi(argv[3]) == 3) {
|
} else if(std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::SSD(model_file, params_file,
|
auto model = fastdeploy::vision::detection::SSD(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -111,7 +111,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ssd_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ssd_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::YOLOv3(model_file, params_file,
|
auto model = fastdeploy::vision::detection::YOLOv3(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -109,7 +109,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PaddleYOLOv5(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PaddleYOLOv5(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -142,7 +142,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if(std::atoi(argv[3]) == 2){
|
} else if(std::atoi(argv[3]) == 2){
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if(std::atoi(argv[3]) == 3){
|
} else if(std::atoi(argv[3]) == 3){
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PaddleYOLOv6(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PaddleYOLOv6(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -141,7 +141,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if(std::atoi(argv[3]) == 2){
|
} else if(std::atoi(argv[3]) == 2){
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if(std::atoi(argv[3]) == 3){
|
} else if(std::atoi(argv[3]) == 3){
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PaddleYOLOv7(model_file, params_file,
|
auto model = fastdeploy::vision::detection::PaddleYOLOv7(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -140,7 +140,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./ppyolo_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if(std::atoi(argv[3]) == 2){
|
} else if(std::atoi(argv[3]) == 2){
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if(std::atoi(argv[3]) == 3){
|
} else if(std::atoi(argv[3]) == 3){
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "infer_cfg.yml";
|
auto config_file = model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::PaddleYOLOX(
|
auto model = fastdeploy::vision::detection::PaddleYOLOX(
|
||||||
model_file, params_file, config_file, option);
|
model_file, params_file, config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -138,7 +138,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./paddle_yolox_dirname ./test.jpeg 0"
|
"e.g ./infer_model ./paddle_yolox_dirname ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu by tensorrt; 3: run with xpu."
|
"with gpu; 2: run with gpu by tensorrt; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ python infer_ppyoloe.py --model_dir ppyoloe_crn_l_300e_coco --image 000000014439
|
|||||||
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python infer_ppyoloe.py --model_dir ppyoloe_crn_l_300e_coco --image 000000014439.jpg --device gpu --use_trt True
|
python infer_ppyoloe.py --model_dir ppyoloe_crn_l_300e_coco --image 000000014439.jpg --device gpu --use_trt True
|
||||||
# 昆仑芯XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer_ppyoloe.py --model_dir ppyoloe_crn_l_300e_coco --image 000000014439.jpg --device xpu
|
python infer_ppyoloe.py --model_dir ppyoloe_crn_l_300e_coco --image 000000014439.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu(autotune=False, l3_workspace_size=0)
|
option.use_kunlunxin(autotune=False, l3_workspace_size=0)
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu(autotune=False, l3_workspace_size=0)
|
option.use_kunlunxin(autotune=False, l3_workspace_size=0)
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
# option.use_gpu()
|
# option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -18,7 +18,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -30,8 +30,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,14 +17,14 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -29,8 +29,8 @@ def parse_arguments():
|
|||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -29,7 +29,7 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
./infer_paddle_demo yolov5s_infer 000000014439.jpg 1
|
./infer_paddle_demo yolov5s_infer 000000014439.jpg 1
|
||||||
# GPU上TensorRT推理
|
# GPU上TensorRT推理
|
||||||
./infer_paddle_demo yolov5s_infer 000000014439.jpg 2
|
./infer_paddle_demo yolov5s_infer 000000014439.jpg 2
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_paddle_demo yolov5s_infer 000000014439.jpg 3
|
./infer_paddle_demo yolov5s_infer 000000014439.jpg 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -102,11 +102,11 @@ void TrtInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
fastdeploy::RuntimeOption option;
|
fastdeploy::RuntimeOption option;
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::detection::YOLOv5(
|
auto model = fastdeploy::vision::detection::YOLOv5(
|
||||||
model_file, params_file, option, fastdeploy::ModelFormat::PADDLE);
|
model_file, params_file, option, fastdeploy::ModelFormat::PADDLE);
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -23,8 +23,8 @@ python infer.py --model yolov5s_infer --image 000000014439.jpg --device cpu
|
|||||||
python infer.py --model yolov5s_infer --image 000000014439.jpg --device gpu
|
python infer.py --model yolov5s_infer --image 000000014439.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理
|
# GPU上使用TensorRT推理
|
||||||
python infer.py --model yolov5s_infer --image 000000014439.jpg --device gpu --use_trt True
|
python infer.py --model yolov5s_infer --image 000000014439.jpg --device gpu --use_trt True
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --model yolov5s_infer --image 000000014439.jpg --device xpu
|
python infer.py --model yolov5s_infer --image 000000014439.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -14,7 +14,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu' or 'gpu' or 'xpu'.")
|
help="Type of inference device, support 'cpu' or 'gpu' or 'kunlunxin'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -25,8 +25,8 @@ def parse_arguments():
|
|||||||
|
|
||||||
def build_option(args):
|
def build_option(args):
|
||||||
option = fd.RuntimeOption()
|
option = fd.RuntimeOption()
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
@@ -19,16 +19,16 @@ cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/fastdeploy-linux-x64-x.x.x
|
|||||||
make -j
|
make -j
|
||||||
|
|
||||||
#下载Paddle模型文件和测试图片
|
#下载Paddle模型文件和测试图片
|
||||||
https://bj.bcebos.com/paddlehub/fastdeploy/yolov6s_infer.tar
|
wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov6s_infer.tar
|
||||||
tar -xf yolov6s_infer.tar
|
tar -xf yolov6s_infer.tar
|
||||||
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
||||||
|
|
||||||
# CPU推理
|
# CPU推理
|
||||||
./infer_paddle_demo ./../yolov6s_infer 000000014439.jpg 0
|
./infer_paddle_demo yolov6s_infer 000000014439.jpg 0
|
||||||
# GPU推理
|
# GPU推理
|
||||||
./infer_paddle_demo ./../yolov6s_infer 000000014439.jpg 1
|
./infer_paddle_demo yolov6s_infer 000000014439.jpg 1
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_paddle_demo ./../yolov6s_infer 000000014439.jpg 2
|
./infer_paddle_demo yolov6s_infer 000000014439.jpg 2
|
||||||
```
|
```
|
||||||
|
|
||||||
如果想要验证ONNX模型的推理,可以参考如下命令:
|
如果想要验证ONNX模型的推理,可以参考如下命令:
|
||||||
|
@@ -45,9 +45,9 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
fastdeploy::RuntimeOption option;
|
fastdeploy::RuntimeOption option;
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto model = fastdeploy::vision::detection::YOLOv6(model_file, params_file, option, fastdeploy::ModelFormat::PADDLE);
|
auto model = fastdeploy::vision::detection::YOLOv6(model_file, params_file, option, fastdeploy::ModelFormat::PADDLE);
|
||||||
@@ -103,7 +103,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./yolov6s_infer ./test.jpeg 0"
|
"e.g ./infer_model ./yolov6s_infer ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with xpu."
|
"with gpu; 2: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer(argv[1], argv[2]);
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd examples/vision/detection/yolov6/python/
|
cd examples/vision/detection/yolov6/python/
|
||||||
|
|
||||||
https://bj.bcebos.com/paddlehub/fastdeploy/yolov6s_infer.tar
|
wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov6s_infer.tar
|
||||||
tar -xf yolov6s_infer.tar
|
tar -xf yolov6s_infer.tar
|
||||||
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
||||||
|
|
||||||
@@ -20,8 +20,8 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device cpu
|
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device cpu
|
||||||
# GPU推理
|
# GPU推理
|
||||||
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device gpu
|
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device gpu
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device xpu
|
python infer_paddle_model.py --model yolov6s_infer --image 000000014439.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
如果想要验证ONNX模型的推理,可以参考如下命令:
|
如果想要验证ONNX模型的推理,可以参考如下命令:
|
||||||
```bash
|
```bash
|
||||||
|
0
examples/vision/detection/yolov6/python/infer.py
Normal file → Executable file
0
examples/vision/detection/yolov6/python/infer.py
Normal file → Executable file
@@ -16,7 +16,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ def build_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu(0)
|
option.use_gpu(0)
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
return option
|
return option
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 0
|
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 0
|
||||||
# GPU推理
|
# GPU推理
|
||||||
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 1
|
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 1
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 2
|
./infer_paddle_model_demo yolov7_infer 000000014439.jpg 2
|
||||||
```
|
```
|
||||||
如果想要验证ONNX模型的推理,可以参考如下命令:
|
如果想要验证ONNX模型的推理,可以参考如下命令:
|
||||||
|
@@ -52,7 +52,7 @@ int main(int argc, char* argv[]) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run on cpu with ORT "
|
std::cout << "The data type of run_option is int, 0: run on cpu with ORT "
|
||||||
"backend; 1: run "
|
"backend; 1: run "
|
||||||
"on gpu with TensorRT backend ; 2: run with xpu. "
|
"on gpu with TensorRT backend ; 2: run with kunlunxin. "
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ int main(int argc, char* argv[]) {
|
|||||||
option.UseGpu();
|
option.UseGpu();
|
||||||
option.UseTrtBackend();
|
option.UseTrtBackend();
|
||||||
} else if (flag == 2) {
|
} else if (flag == 2) {
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string model_dir = argv[1];
|
std::string model_dir = argv[1];
|
||||||
|
@@ -22,8 +22,8 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device cpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device cpu
|
||||||
# GPU推理
|
# GPU推理
|
||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device gpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device gpu
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device xpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
如果想要验证ONNX模型的推理,可以参考如下命令:
|
如果想要验证ONNX模型的推理,可以参考如下命令:
|
||||||
```bash
|
```bash
|
||||||
|
@@ -22,8 +22,8 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device cpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device cpu
|
||||||
# GPU
|
# GPU
|
||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device gpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device gpu
|
||||||
# XPU
|
# KunlunXin XPU
|
||||||
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device xpu
|
python infer_paddle_model.py --model yolov7_infer --image 000000014439.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
If you want to test ONNX model:
|
If you want to test ONNX model:
|
||||||
```bash
|
```bash
|
||||||
|
0
examples/vision/detection/yolov7/python/infer.py
Normal file → Executable file
0
examples/vision/detection/yolov7/python/infer.py
Normal file → Executable file
@@ -16,7 +16,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ def build_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu(0)
|
option.use_gpu(0)
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
return option
|
return option
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ tar zxvf mobilefacenet_adaface.tgz -C ./
|
|||||||
mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
||||||
face_0.jpg face_1.jpg face_2.jpg 2
|
face_0.jpg face_1.jpg face_2.jpg 2
|
||||||
|
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo mobilefacenet_adaface/mobilefacenet_adaface.pdmodel \
|
./infer_demo mobilefacenet_adaface/mobilefacenet_adaface.pdmodel \
|
||||||
mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
||||||
face_0.jpg face_1.jpg face_2.jpg 3
|
face_0.jpg face_1.jpg face_2.jpg 3
|
||||||
|
@@ -52,10 +52,10 @@ void CpuInfer(const std::string &model_file, const std::string ¶ms_file,
|
|||||||
<< ", Cosine 02:" << cosine02 << std::endl;
|
<< ", Cosine 02:" << cosine02 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string &model_file, const std::string ¶ms_file,
|
void KunlunXinInfer(const std::string &model_file, const std::string ¶ms_file,
|
||||||
const std::vector<std::string> &image_file) {
|
const std::vector<std::string> &image_file) {
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::faceid::AdaFace(model_file, params_file);
|
auto model = fastdeploy::vision::faceid::AdaFace(model_file, params_file);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
std::cerr << "Failed to initialize." << std::endl;
|
std::cerr << "Failed to initialize." << std::endl;
|
||||||
@@ -182,7 +182,7 @@ int main(int argc, char *argv[]) {
|
|||||||
"test_lite_focal_AdaFace_2.JPG 0"
|
"test_lite_focal_AdaFace_2.JPG 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if (std::atoi(argv[6]) == 2) {
|
} else if (std::atoi(argv[6]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2], image_files);
|
TrtInfer(argv[1], argv[2], image_files);
|
||||||
} else if (std::atoi(argv[6]) == 3) {
|
} else if (std::atoi(argv[6]) == 3) {
|
||||||
CpuInfer(argv[1], argv[2], image_files);
|
KunlunXinInfer(argv[1], argv[2], image_files);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -45,13 +45,13 @@ python infer.py --model mobilefacenet_adaface/mobilefacenet_adaface.pdmodel \
|
|||||||
--device gpu \
|
--device gpu \
|
||||||
--use_trt True
|
--use_trt True
|
||||||
|
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --model mobilefacenet_adaface/mobilefacenet_adaface.pdmodel \
|
python infer.py --model mobilefacenet_adaface/mobilefacenet_adaface.pdmodel \
|
||||||
--params_file mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
--params_file mobilefacenet_adaface/mobilefacenet_adaface.pdiparams \
|
||||||
--face test_lite_focal_arcface_0.JPG \
|
--face test_lite_focal_arcface_0.JPG \
|
||||||
--face_positive test_lite_focal_arcface_1.JPG \
|
--face_positive test_lite_focal_arcface_1.JPG \
|
||||||
--face_negative test_lite_focal_arcface_2.JPG \
|
--face_negative test_lite_focal_arcface_2.JPG \
|
||||||
--device xpu
|
--device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -39,7 +39,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu' , 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu' , 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -54,8 +54,8 @@ def build_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.use_trt:
|
if args.use_trt:
|
||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
|
@@ -33,7 +33,7 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/000000018491.jpg
|
|||||||
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 1
|
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 1
|
||||||
# GPU上TensorRT推理
|
# GPU上TensorRT推理
|
||||||
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 2
|
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 2
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 3
|
./infer_demo PP_PicoDet_V2_S_Pedestrian_320x320_infer PP_TinyPose_256x192_infer 000000018491.jpg 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -66,11 +66,11 @@ void CpuInfer(const std::string& det_model_dir,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& det_model_dir,
|
void KunlunXinInfer(const std::string& det_model_dir,
|
||||||
const std::string& tinypose_model_dir,
|
const std::string& tinypose_model_dir,
|
||||||
const std::string& image_file) {
|
const std::string& image_file) {
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto det_model_file = det_model_dir + sep + "model.pdmodel";
|
auto det_model_file = det_model_dir + sep + "model.pdmodel";
|
||||||
auto det_params_file = det_model_dir + sep + "model.pdiparams";
|
auto det_params_file = det_model_dir + sep + "model.pdiparams";
|
||||||
auto det_config_file = det_model_dir + sep + "infer_cfg.yml";
|
auto det_config_file = det_model_dir + sep + "infer_cfg.yml";
|
||||||
@@ -229,7 +229,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"./test.jpeg 0"
|
"./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[4]) == 2) {
|
} else if (std::atoi(argv[4]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2], argv[3]);
|
TrtInfer(argv[1], argv[2], argv[3]);
|
||||||
} else if (std::atoi(argv[4]) == 3) {
|
} else if (std::atoi(argv[4]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2], argv[3]);
|
KunlunXinInfer(argv[1], argv[2], argv[3]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infe
|
|||||||
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu
|
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu --use_trt True
|
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu --use_trt True
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device xpu
|
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -19,7 +19,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -47,8 +47,8 @@ def build_tinypose_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.use_trt:
|
if args.use_trt:
|
||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
|
@@ -32,7 +32,7 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/hrnet_demo.jpg
|
|||||||
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 1
|
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 1
|
||||||
# GPU上TensorRT推理
|
# GPU上TensorRT推理
|
||||||
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 2
|
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 2
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 3
|
./infer_tinypose_demo PP_TinyPose_256x192_infer hrnet_demo.jpg 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -53,13 +53,13 @@ void CpuInfer(const std::string& tinypose_model_dir,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& tinypose_model_dir,
|
void KunlunXinInfer(const std::string& tinypose_model_dir,
|
||||||
const std::string& image_file) {
|
const std::string& image_file) {
|
||||||
auto tinypose_model_file = tinypose_model_dir + sep + "model.pdmodel";
|
auto tinypose_model_file = tinypose_model_dir + sep + "model.pdmodel";
|
||||||
auto tinypose_params_file = tinypose_model_dir + sep + "model.pdiparams";
|
auto tinypose_params_file = tinypose_model_dir + sep + "model.pdiparams";
|
||||||
auto tinypose_config_file = tinypose_model_dir + sep + "infer_cfg.yml";
|
auto tinypose_config_file = tinypose_model_dir + sep + "infer_cfg.yml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto tinypose_model = fastdeploy::vision::keypointdetection::PPTinyPose(
|
auto tinypose_model = fastdeploy::vision::keypointdetection::PPTinyPose(
|
||||||
tinypose_model_file, tinypose_params_file, tinypose_config_file, option);
|
tinypose_model_file, tinypose_params_file, tinypose_config_file, option);
|
||||||
if (!tinypose_model.Initialized()) {
|
if (!tinypose_model.Initialized()) {
|
||||||
@@ -163,7 +163,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./pptinypose_model_dir ./test.jpeg 0"
|
"e.g ./infer_model ./pptinypose_model_dir ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --imag
|
|||||||
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device gpu
|
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device gpu --use_trt True
|
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device gpu --use_trt True
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device xpu
|
python pptinypose_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --image hrnet_demo.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -17,7 +17,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -32,8 +32,8 @@ def build_tinypose_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.use_trt:
|
if args.use_trt:
|
||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
|
@@ -31,7 +31,7 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/matting_bgr.jpg
|
|||||||
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 1
|
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 1
|
||||||
# GPU上TensorRT推理
|
# GPU上TensorRT推理
|
||||||
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 2
|
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 2
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 3
|
./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -51,13 +51,13 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file,
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file,
|
||||||
const std::string& background_file) {
|
const std::string& background_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "deploy.yaml";
|
auto config_file = model_dir + sep + "deploy.yaml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::matting::PPMatting(model_file, params_file,
|
auto model = fastdeploy::vision::matting::PPMatting(model_file, params_file,
|
||||||
config_file, option);
|
config_file, option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
@@ -156,7 +156,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./PP-Matting-512 ./test.jpg ./test_bg.jpg 0"
|
"e.g ./infer_model ./PP-Matting-512 ./test.jpg ./test_bg.jpg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend, 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend, 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[4]) == 2) {
|
} else if (std::atoi(argv[4]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2], argv[3]);
|
TrtInfer(argv[1], argv[2], argv[3]);
|
||||||
} else if (std::atoi(argv[4]) == 3) {
|
} else if (std::atoi(argv[4]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2], argv[3]);
|
KunlunXinInfer(argv[1], argv[2], argv[3]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -23,8 +23,8 @@ python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bg
|
|||||||
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu
|
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu --use_trt True
|
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu --use_trt True
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device xpu
|
python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -21,7 +21,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -40,8 +40,8 @@ def build_option(args):
|
|||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
option.set_trt_input_shape("img", [1, 3, 512, 512])
|
option.set_trt_input_shape("img", [1, 3, 512, 512])
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
return option
|
return option
|
||||||
|
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/ppocr/utils/ppocr_
|
|||||||
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 2
|
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 2
|
||||||
# GPU上Paddle-TRT推理
|
# GPU上Paddle-TRT推理
|
||||||
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 3
|
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 3
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 4
|
./infer_demo ./ch_PP-OCRv2_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv2_rec_infer ./ppocr_keys_v1.txt ./12.jpg 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"./ppocr_keys_v1.txt ./12.jpg 0"
|
"./ppocr_keys_v1.txt ./12.jpg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with gpu and use Paddle-TRT; 4: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with gpu and use Paddle-TRT; 4: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ int main(int argc, char* argv[]) {
|
|||||||
option.EnablePaddleTrtCollectShape();
|
option.EnablePaddleTrtCollectShape();
|
||||||
option.EnablePaddleToTrt();
|
option.EnablePaddleToTrt();
|
||||||
} else if (flag == 4) {
|
} else if (flag == 4) {
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string det_model_dir = argv[1];
|
std::string det_model_dir = argv[1];
|
||||||
|
@@ -34,8 +34,8 @@ python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2
|
|||||||
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu
|
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理
|
# GPU上使用TensorRT推理
|
||||||
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu --backend trt
|
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu --backend trt
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device xpu
|
python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv2_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -41,7 +41,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--backend",
|
"--backend",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -68,8 +68,8 @@ def build_option(args):
|
|||||||
|
|
||||||
option.set_cpu_thread_num(args.cpu_thread_num)
|
option.set_cpu_thread_num(args.cpu_thread_num)
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
return option
|
return option
|
||||||
|
|
||||||
if args.backend.lower() == "trt":
|
if args.backend.lower() == "trt":
|
||||||
|
@@ -41,7 +41,7 @@ wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/ppocr/utils/ppocr_
|
|||||||
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 2
|
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 2
|
||||||
# GPU上Paddle-TRT推理
|
# GPU上Paddle-TRT推理
|
||||||
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 3
|
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 3
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 4
|
./infer_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"./ppocr_keys_v1.txt ./12.jpg 0"
|
"./ppocr_keys_v1.txt ./12.jpg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with gpu and use Paddle-TRT; 4: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with gpu and use Paddle-TRT; 4: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ int main(int argc, char* argv[]) {
|
|||||||
option.EnablePaddleTrtCollectShape();
|
option.EnablePaddleTrtCollectShape();
|
||||||
option.EnablePaddleToTrt();
|
option.EnablePaddleToTrt();
|
||||||
} else if (flag == 4) {
|
} else if (flag == 4) {
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string det_model_dir = argv[1];
|
std::string det_model_dir = argv[1];
|
||||||
|
@@ -33,8 +33,8 @@ python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2
|
|||||||
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu
|
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu
|
||||||
# GPU上使用TensorRT推理
|
# GPU上使用TensorRT推理
|
||||||
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu --backend trt
|
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu --backend trt
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device xpu
|
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -41,7 +41,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'cpu', 'xpu' or 'gpu'.")
|
help="Type of inference device, support 'cpu', 'kunlunxin' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--backend",
|
"--backend",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -68,8 +68,8 @@ def build_option(args):
|
|||||||
|
|
||||||
option.set_cpu_thread_num(args.cpu_thread_num)
|
option.set_cpu_thread_num(args.cpu_thread_num)
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
return option
|
return option
|
||||||
|
|
||||||
if args.backend.lower() == "trt":
|
if args.backend.lower() == "trt":
|
||||||
|
@@ -32,7 +32,7 @@ wget https://paddleseg.bj.bcebos.com/dygraph/demo/cityscapes_demo.png
|
|||||||
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 1
|
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 1
|
||||||
# GPU上TensorRT推理
|
# GPU上TensorRT推理
|
||||||
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 2
|
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 2
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 3
|
./infer_demo Unet_cityscapes_without_argmax_infer cityscapes_demo.png 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -48,12 +48,12 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XpuInfer(const std::string& model_dir, const std::string& image_file) {
|
void KunlunXinInfer(const std::string& model_dir, const std::string& image_file) {
|
||||||
auto model_file = model_dir + sep + "model.pdmodel";
|
auto model_file = model_dir + sep + "model.pdmodel";
|
||||||
auto params_file = model_dir + sep + "model.pdiparams";
|
auto params_file = model_dir + sep + "model.pdiparams";
|
||||||
auto config_file = model_dir + sep + "deploy.yaml";
|
auto config_file = model_dir + sep + "deploy.yaml";
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseXpu();
|
option.UseKunlunXin();
|
||||||
auto model = fastdeploy::vision::segmentation::PaddleSegModel(
|
auto model = fastdeploy::vision::segmentation::PaddleSegModel(
|
||||||
model_file, params_file, config_file, option);
|
model_file, params_file, config_file, option);
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ int main(int argc, char* argv[]) {
|
|||||||
"e.g ./infer_model ./ppseg_model_dir ./test.jpeg 0"
|
"e.g ./infer_model ./ppseg_model_dir ./test.jpeg 0"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
std::cout << "The data type of run_option is int, 0: run with cpu; 1: run "
|
||||||
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with xpu."
|
"with gpu; 2: run with gpu and use tensorrt backend; 3: run with kunlunxin."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer(argv[1], argv[2]);
|
TrtInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 3) {
|
} else if (std::atoi(argv[3]) == 3) {
|
||||||
XpuInfer(argv[1], argv[2]);
|
KunlunXinInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_
|
|||||||
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device gpu
|
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device gpu
|
||||||
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
# GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待)
|
||||||
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device gpu --use_trt True
|
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device gpu --use_trt True
|
||||||
# XPU推理
|
# 昆仑芯XPU推理
|
||||||
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device xpu
|
python infer.py --model Unet_cityscapes_without_argmax_infer --image cityscapes_demo.png --device kunlunxin
|
||||||
```
|
```
|
||||||
|
|
||||||
运行完成可视化结果如下图所示
|
运行完成可视化结果如下图所示
|
||||||
|
@@ -15,7 +15,7 @@ def parse_arguments():
|
|||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default='cpu',
|
default='cpu',
|
||||||
help="Type of inference device, support 'xpu', 'cpu' or 'gpu'.")
|
help="Type of inference device, support 'kunlunxin', 'cpu' or 'gpu'.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use_trt",
|
"--use_trt",
|
||||||
type=ast.literal_eval,
|
type=ast.literal_eval,
|
||||||
@@ -30,8 +30,8 @@ def build_option(args):
|
|||||||
if args.device.lower() == "gpu":
|
if args.device.lower() == "gpu":
|
||||||
option.use_gpu()
|
option.use_gpu()
|
||||||
|
|
||||||
if args.device.lower() == "xpu":
|
if args.device.lower() == "kunlunxin":
|
||||||
option.use_xpu()
|
option.use_kunlunxin()
|
||||||
|
|
||||||
if args.use_trt:
|
if args.use_trt:
|
||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
|
@@ -43,7 +43,7 @@ void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
|||||||
option_ = option;
|
option_ = option;
|
||||||
std::vector<paddle::lite_api::Place> valid_places;
|
std::vector<paddle::lite_api::Place> valid_places;
|
||||||
if (option_.enable_int8) {
|
if (option_.enable_int8) {
|
||||||
if(option_.enable_xpu) {
|
if(option_.enable_kunlunxin) {
|
||||||
valid_places.push_back(
|
valid_places.push_back(
|
||||||
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kInt8)});
|
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kInt8)});
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +54,7 @@ void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
|||||||
<< "inference with int8 precision!" << std::endl;
|
<< "inference with int8 precision!" << std::endl;
|
||||||
}
|
}
|
||||||
if (option_.enable_fp16) {
|
if (option_.enable_fp16) {
|
||||||
if(option_.enable_xpu){
|
if(option_.enable_kunlunxin){
|
||||||
valid_places.push_back(
|
valid_places.push_back(
|
||||||
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kFP16)});
|
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kFP16)});
|
||||||
} else {
|
} else {
|
||||||
@@ -127,17 +127,17 @@ void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
|||||||
paddle::lite_api::Place{TARGET(kARM), PRECISION(kInt8)});
|
paddle::lite_api::Place{TARGET(kARM), PRECISION(kInt8)});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(option_.enable_xpu){
|
if(option_.enable_kunlunxin){
|
||||||
valid_places.push_back(
|
valid_places.push_back(
|
||||||
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kFloat)});
|
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kFloat)});
|
||||||
valid_places.push_back(
|
valid_places.push_back(
|
||||||
paddle::lite_api::Place{TARGET(kX86), PRECISION(kFloat)});
|
paddle::lite_api::Place{TARGET(kX86), PRECISION(kFloat)});
|
||||||
config_.set_xpu_dev_per_thread(option_.device_id);
|
config_.set_xpu_dev_per_thread(option_.device_id);
|
||||||
config_.set_xpu_workspace_l3_size_per_thread(option_.xpu_l3_workspace_size);
|
config_.set_xpu_workspace_l3_size_per_thread(option_.kunlunxin_l3_workspace_size);
|
||||||
config_.set_xpu_l3_cache_method(option_.xpu_l3_workspace_size, option_.xpu_locked);
|
config_.set_xpu_l3_cache_method(option_.kunlunxin_l3_workspace_size, option_.kunlunxin_locked);
|
||||||
config_.set_xpu_conv_autotune(option_.xpu_autotune, option_.xpu_autotune_file);
|
config_.set_xpu_conv_autotune(option_.kunlunxin_autotune, option_.kunlunxin_autotune_file);
|
||||||
config_.set_xpu_multi_encoder_method(option_.xpu_precision, option_.xpu_adaptive_seqlen);
|
config_.set_xpu_multi_encoder_method(option_.kunlunxin_precision, option_.kunlunxin_adaptive_seqlen);
|
||||||
if (option_.xpu_enable_multi_stream) {
|
if (option_.kunlunxin_enable_multi_stream) {
|
||||||
config_.enable_xpu_multi_stream();
|
config_.enable_xpu_multi_stream();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -221,7 +221,7 @@ bool LiteBackend::InitFromPaddle(const std::string& model_file,
|
|||||||
auto shape = tensor->shape();
|
auto shape = tensor->shape();
|
||||||
info.shape.assign(shape.begin(), shape.end());
|
info.shape.assign(shape.begin(), shape.end());
|
||||||
info.name = output_names[i];
|
info.name = output_names[i];
|
||||||
if(!option_.enable_xpu){
|
if(!option_.enable_kunlunxin){
|
||||||
info.dtype = LiteDataTypeToFD(tensor->precision());
|
info.dtype = LiteDataTypeToFD(tensor->precision());
|
||||||
}
|
}
|
||||||
outputs_desc_.emplace_back(info);
|
outputs_desc_.emplace_back(info);
|
||||||
|
@@ -53,15 +53,15 @@ struct LiteBackendOption {
|
|||||||
std::vector<std::string> nnadapter_device_names = {};
|
std::vector<std::string> nnadapter_device_names = {};
|
||||||
bool enable_timvx = false;
|
bool enable_timvx = false;
|
||||||
bool enable_ascend = false;
|
bool enable_ascend = false;
|
||||||
bool enable_xpu = false;
|
bool enable_kunlunxin = false;
|
||||||
int device_id = 0;
|
int device_id = 0;
|
||||||
int xpu_l3_workspace_size = 0xfffc00;
|
int kunlunxin_l3_workspace_size = 0xfffc00;
|
||||||
bool xpu_locked = false;
|
bool kunlunxin_locked = false;
|
||||||
bool xpu_autotune = true;
|
bool kunlunxin_autotune = true;
|
||||||
std::string xpu_autotune_file = "";
|
std::string kunlunxin_autotune_file = "";
|
||||||
std::string xpu_precision = "int16";
|
std::string kunlunxin_precision = "int16";
|
||||||
bool xpu_adaptive_seqlen = false;
|
bool kunlunxin_adaptive_seqlen = false;
|
||||||
bool xpu_enable_multi_stream = false;
|
bool kunlunxin_enable_multi_stream = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert data type from paddle lite to fastdeploy
|
// Convert data type from paddle lite to fastdeploy
|
||||||
|
@@ -65,8 +65,8 @@ std::string Str(const Device& d) {
|
|||||||
case Device::ASCEND:
|
case Device::ASCEND:
|
||||||
out = "Device::ASCEND";
|
out = "Device::ASCEND";
|
||||||
break;
|
break;
|
||||||
case Device::XPU:
|
case Device::KUNLUNXIN:
|
||||||
out = "Device::XPU";
|
out = "Device::KUNLUNXIN";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
out = "Device::UNKOWN";
|
out = "Device::UNKOWN";
|
||||||
@@ -88,8 +88,8 @@ std::ostream& operator<<(std::ostream& out,const Device& d){
|
|||||||
case Device::TIMVX:
|
case Device::TIMVX:
|
||||||
out << "Device::TIMVX";
|
out << "Device::TIMVX";
|
||||||
break;
|
break;
|
||||||
case Device::XPU:
|
case Device::KUNLUNXIN:
|
||||||
out << "Device::XPU";
|
out << "Device::KUNLUNXIN";
|
||||||
break;
|
break;
|
||||||
case Device::ASCEND:
|
case Device::ASCEND:
|
||||||
out << "Device::ASCEND";
|
out << "Device::ASCEND";
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
|
||||||
enum FASTDEPLOY_DECL Device { CPU, GPU, RKNPU, IPU, TIMVX, XPU, ASCEND};
|
enum FASTDEPLOY_DECL Device { CPU, GPU, RKNPU, IPU, TIMVX, KUNLUNXIN, ASCEND};
|
||||||
|
|
||||||
FASTDEPLOY_DECL std::string Str(const Device& d);
|
FASTDEPLOY_DECL std::string Str(const Device& d);
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ bool FastDeployModel::InitRuntimeWithSpecifiedBackend() {
|
|||||||
bool use_rknpu = (runtime_option.device == Device::RKNPU);
|
bool use_rknpu = (runtime_option.device == Device::RKNPU);
|
||||||
bool use_timvx = (runtime_option.device == Device::TIMVX);
|
bool use_timvx = (runtime_option.device == Device::TIMVX);
|
||||||
bool use_ascend = (runtime_option.device == Device::ASCEND);
|
bool use_ascend = (runtime_option.device == Device::ASCEND);
|
||||||
bool use_xpu = (runtime_option.device == Device::XPU);
|
bool use_kunlunxin = (runtime_option.device == Device::KUNLUNXIN);
|
||||||
|
|
||||||
if (use_gpu) {
|
if (use_gpu) {
|
||||||
if (!IsSupported(valid_gpu_backends, runtime_option.backend)) {
|
if (!IsSupported(valid_gpu_backends, runtime_option.backend)) {
|
||||||
@@ -74,9 +74,9 @@ bool FastDeployModel::InitRuntimeWithSpecifiedBackend() {
|
|||||||
FDERROR << "The valid ascend backends of model " << ModelName() << " are " << Str(valid_ascend_backends) << ", " << runtime_option.backend << " is not supported." << std::endl;
|
FDERROR << "The valid ascend backends of model " << ModelName() << " are " << Str(valid_ascend_backends) << ", " << runtime_option.backend << " is not supported." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (use_xpu) {
|
} else if (use_kunlunxin) {
|
||||||
if (!IsSupported(valid_xpu_backends, runtime_option.backend)) {
|
if (!IsSupported(valid_kunlunxin_backends, runtime_option.backend)) {
|
||||||
FDERROR << "The valid xpu backends of model " << ModelName() << " are " << Str(valid_xpu_backends) << ", " << runtime_option.backend << " is not supported." << std::endl;
|
FDERROR << "The valid kunlunxin backends of model " << ModelName() << " are " << Str(valid_kunlunxin_backends) << ", " << runtime_option.backend << " is not supported." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if(use_ipu) {
|
} else if(use_ipu) {
|
||||||
@@ -116,8 +116,8 @@ bool FastDeployModel::InitRuntimeWithSpecifiedDevice() {
|
|||||||
return CreateTimVXBackend();
|
return CreateTimVXBackend();
|
||||||
} else if (runtime_option.device == Device::ASCEND) {
|
} else if (runtime_option.device == Device::ASCEND) {
|
||||||
return CreateASCENDBackend();
|
return CreateASCENDBackend();
|
||||||
} else if (runtime_option.device == Device::XPU) {
|
} else if (runtime_option.device == Device::KUNLUNXIN) {
|
||||||
return CreateXPUBackend();
|
return CreateKunlunXinBackend();
|
||||||
} else if (runtime_option.device == Device::IPU) {
|
} else if (runtime_option.device == Device::IPU) {
|
||||||
#ifdef WITH_IPU
|
#ifdef WITH_IPU
|
||||||
return CreateIpuBackend();
|
return CreateIpuBackend();
|
||||||
@@ -127,7 +127,7 @@ bool FastDeployModel::InitRuntimeWithSpecifiedDevice() {
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
FDERROR << "Only support CPU/GPU/IPU/RKNPU/TIMVX/XPU/ASCEND now." << std::endl;
|
FDERROR << "Only support CPU/GPU/IPU/RKNPU/TIMVX/KunlunXin/ASCEND now." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,18 +241,18 @@ bool FastDeployModel::CreateTimVXBackend() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FastDeployModel::CreateXPUBackend() {
|
bool FastDeployModel::CreateKunlunXinBackend() {
|
||||||
if (valid_xpu_backends.size() == 0) {
|
if (valid_kunlunxin_backends.size() == 0) {
|
||||||
FDERROR << "There's no valid xpu backends for model: " << ModelName()
|
FDERROR << "There's no valid KunlunXin backends for model: " << ModelName()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < valid_xpu_backends.size(); ++i) {
|
for (size_t i = 0; i < valid_kunlunxin_backends.size(); ++i) {
|
||||||
if (!IsBackendAvailable(valid_xpu_backends[i])) {
|
if (!IsBackendAvailable(valid_kunlunxin_backends[i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
runtime_option.backend = valid_xpu_backends[i];
|
runtime_option.backend = valid_kunlunxin_backends[i];
|
||||||
runtime_ = std::unique_ptr<Runtime>(new Runtime());
|
runtime_ = std::unique_ptr<Runtime>(new Runtime());
|
||||||
if (!runtime_->Init(runtime_option)) {
|
if (!runtime_->Init(runtime_option)) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -50,7 +50,7 @@ class FASTDEPLOY_DECL FastDeployModel {
|
|||||||
std::vector<Backend> valid_ascend_backends = {};
|
std::vector<Backend> valid_ascend_backends = {};
|
||||||
/** Model's valid KunlunXin xpu backends. This member defined all the KunlunXin xpu backends have successfully tested for the model
|
/** Model's valid KunlunXin xpu backends. This member defined all the KunlunXin xpu backends have successfully tested for the model
|
||||||
*/
|
*/
|
||||||
std::vector<Backend> valid_xpu_backends = {};
|
std::vector<Backend> valid_kunlunxin_backends = {};
|
||||||
/** Model's valid hardware backends. This member defined all the gpu backends have successfully tested for the model
|
/** Model's valid hardware backends. This member defined all the gpu backends have successfully tested for the model
|
||||||
*/
|
*/
|
||||||
std::vector<Backend> valid_rknpu_backends = {};
|
std::vector<Backend> valid_rknpu_backends = {};
|
||||||
@@ -149,7 +149,7 @@ class FASTDEPLOY_DECL FastDeployModel {
|
|||||||
bool CreateIpuBackend();
|
bool CreateIpuBackend();
|
||||||
bool CreateRKNPUBackend();
|
bool CreateRKNPUBackend();
|
||||||
bool CreateTimVXBackend();
|
bool CreateTimVXBackend();
|
||||||
bool CreateXPUBackend();
|
bool CreateKunlunXinBackend();
|
||||||
bool CreateASCENDBackend();
|
bool CreateASCENDBackend();
|
||||||
|
|
||||||
std::shared_ptr<Runtime> runtime_;
|
std::shared_ptr<Runtime> runtime_;
|
||||||
|
@@ -25,7 +25,7 @@ void BindRuntime(pybind11::module& m) {
|
|||||||
.def("use_cpu", &RuntimeOption::UseCpu)
|
.def("use_cpu", &RuntimeOption::UseCpu)
|
||||||
.def("use_rknpu2", &RuntimeOption::UseRKNPU2)
|
.def("use_rknpu2", &RuntimeOption::UseRKNPU2)
|
||||||
.def("use_ascend", &RuntimeOption::UseAscend)
|
.def("use_ascend", &RuntimeOption::UseAscend)
|
||||||
.def("use_xpu", &RuntimeOption::UseXpu)
|
.def("use_kunlunxin", &RuntimeOption::UseKunlunXin)
|
||||||
.def("set_external_stream", &RuntimeOption::SetExternalStream)
|
.def("set_external_stream", &RuntimeOption::SetExternalStream)
|
||||||
.def("set_cpu_thread_num", &RuntimeOption::SetCpuThreadNum)
|
.def("set_cpu_thread_num", &RuntimeOption::SetCpuThreadNum)
|
||||||
.def("use_paddle_backend", &RuntimeOption::UsePaddleBackend)
|
.def("use_paddle_backend", &RuntimeOption::UsePaddleBackend)
|
||||||
@@ -114,20 +114,20 @@ void BindRuntime(pybind11::module& m) {
|
|||||||
&RuntimeOption::ipu_available_memory_proportion)
|
&RuntimeOption::ipu_available_memory_proportion)
|
||||||
.def_readwrite("ipu_enable_half_partial",
|
.def_readwrite("ipu_enable_half_partial",
|
||||||
&RuntimeOption::ipu_enable_half_partial)
|
&RuntimeOption::ipu_enable_half_partial)
|
||||||
.def_readwrite("xpu_l3_workspace_size",
|
.def_readwrite("kunlunxin_l3_workspace_size",
|
||||||
&RuntimeOption::xpu_l3_workspace_size)
|
&RuntimeOption::kunlunxin_l3_workspace_size)
|
||||||
.def_readwrite("xpu_locked",
|
.def_readwrite("kunlunxin_locked",
|
||||||
&RuntimeOption::xpu_locked)
|
&RuntimeOption::kunlunxin_locked)
|
||||||
.def_readwrite("xpu_autotune",
|
.def_readwrite("kunlunxin_autotune",
|
||||||
&RuntimeOption::xpu_autotune)
|
&RuntimeOption::kunlunxin_autotune)
|
||||||
.def_readwrite("xpu_autotune_file",
|
.def_readwrite("kunlunxin_autotune_file",
|
||||||
&RuntimeOption::xpu_autotune_file)
|
&RuntimeOption::kunlunxin_autotune_file)
|
||||||
.def_readwrite("xpu_precision",
|
.def_readwrite("kunlunxin_precision",
|
||||||
&RuntimeOption::xpu_precision)
|
&RuntimeOption::kunlunxin_precision)
|
||||||
.def_readwrite("xpu_adaptive_seqlen",
|
.def_readwrite("kunlunxin_adaptive_seqlen",
|
||||||
&RuntimeOption::xpu_adaptive_seqlen)
|
&RuntimeOption::kunlunxin_adaptive_seqlen)
|
||||||
.def_readwrite("xpu_enable_multi_stream",
|
.def_readwrite("kunlunxin_enable_multi_stream",
|
||||||
&RuntimeOption::xpu_enable_multi_stream);
|
&RuntimeOption::kunlunxin_enable_multi_stream);
|
||||||
|
|
||||||
pybind11::class_<TensorInfo>(m, "TensorInfo")
|
pybind11::class_<TensorInfo>(m, "TensorInfo")
|
||||||
.def_readwrite("name", &TensorInfo::name)
|
.def_readwrite("name", &TensorInfo::name)
|
||||||
|
@@ -263,7 +263,7 @@ void RuntimeOption::UseTimVX() {
|
|||||||
device = Device::TIMVX;
|
device = Device::TIMVX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuntimeOption::UseXpu(int xpu_id,
|
void RuntimeOption::UseKunlunXin(int kunlunxin_id,
|
||||||
int l3_workspace_size,
|
int l3_workspace_size,
|
||||||
bool locked,
|
bool locked,
|
||||||
bool autotune,
|
bool autotune,
|
||||||
@@ -271,16 +271,16 @@ void RuntimeOption::UseXpu(int xpu_id,
|
|||||||
const std::string &precision,
|
const std::string &precision,
|
||||||
bool adaptive_seqlen,
|
bool adaptive_seqlen,
|
||||||
bool enable_multi_stream) {
|
bool enable_multi_stream) {
|
||||||
enable_xpu = true;
|
enable_kunlunxin = true;
|
||||||
device_id = xpu_id;
|
device_id = kunlunxin_id;
|
||||||
xpu_l3_workspace_size = l3_workspace_size;
|
kunlunxin_l3_workspace_size = l3_workspace_size;
|
||||||
xpu_locked=locked;
|
kunlunxin_locked=locked;
|
||||||
xpu_autotune=autotune;
|
kunlunxin_autotune=autotune;
|
||||||
xpu_autotune_file=autotune_file;
|
kunlunxin_autotune_file=autotune_file;
|
||||||
xpu_precision = precision;
|
kunlunxin_precision = precision;
|
||||||
xpu_adaptive_seqlen=adaptive_seqlen;
|
kunlunxin_adaptive_seqlen=adaptive_seqlen;
|
||||||
xpu_enable_multi_stream=enable_multi_stream;
|
kunlunxin_enable_multi_stream=enable_multi_stream;
|
||||||
device = Device::XPU;
|
device = Device::KUNLUNXIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuntimeOption::UseAscend(){
|
void RuntimeOption::UseAscend(){
|
||||||
@@ -611,8 +611,8 @@ bool Runtime::Init(const RuntimeOption& _option) {
|
|||||||
FDINFO << "Runtime initialized with Backend::OPENVINO in "
|
FDINFO << "Runtime initialized with Backend::OPENVINO in "
|
||||||
<< Str(option.device) << "." << std::endl;
|
<< Str(option.device) << "." << std::endl;
|
||||||
} else if (option.backend == Backend::LITE) {
|
} else if (option.backend == Backend::LITE) {
|
||||||
FDASSERT(option.device == Device::CPU || option.device == Device::TIMVX || option.device == Device::XPU || option.device == Device::ASCEND,
|
FDASSERT(option.device == Device::CPU || option.device == Device::TIMVX || option.device == Device::KUNLUNXIN || option.device == Device::ASCEND,
|
||||||
"Backend::LITE only supports Device::CPU/Device::TIMVX/Device::XPU.");
|
"Backend::LITE only supports Device::CPU/Device::TIMVX/Device::KUNLUNXIN.");
|
||||||
CreateLiteBackend();
|
CreateLiteBackend();
|
||||||
FDINFO << "Runtime initialized with Backend::LITE in " << Str(option.device)
|
FDINFO << "Runtime initialized with Backend::LITE in " << Str(option.device)
|
||||||
<< "." << std::endl;
|
<< "." << std::endl;
|
||||||
@@ -882,15 +882,15 @@ void Runtime::CreateLiteBackend() {
|
|||||||
lite_option.nnadapter_mixed_precision_quantization_config_path = option.lite_nnadapter_mixed_precision_quantization_config_path;
|
lite_option.nnadapter_mixed_precision_quantization_config_path = option.lite_nnadapter_mixed_precision_quantization_config_path;
|
||||||
lite_option.enable_timvx = option.enable_timvx;
|
lite_option.enable_timvx = option.enable_timvx;
|
||||||
lite_option.enable_ascend = option.enable_ascend;
|
lite_option.enable_ascend = option.enable_ascend;
|
||||||
lite_option.enable_xpu = option.enable_xpu;
|
lite_option.enable_kunlunxin = option.enable_kunlunxin;
|
||||||
lite_option.device_id = option.device_id;
|
lite_option.device_id = option.device_id;
|
||||||
lite_option.xpu_l3_workspace_size = option.xpu_l3_workspace_size;
|
lite_option.kunlunxin_l3_workspace_size = option.kunlunxin_l3_workspace_size;
|
||||||
lite_option.xpu_locked = option.xpu_locked;
|
lite_option.kunlunxin_locked = option.kunlunxin_locked;
|
||||||
lite_option.xpu_autotune = option.xpu_autotune;
|
lite_option.kunlunxin_autotune = option.kunlunxin_autotune;
|
||||||
lite_option.xpu_autotune_file = option.xpu_autotune_file;
|
lite_option.kunlunxin_autotune_file = option.kunlunxin_autotune_file;
|
||||||
lite_option.xpu_precision = option.xpu_precision;
|
lite_option.kunlunxin_precision = option.kunlunxin_precision;
|
||||||
lite_option.xpu_adaptive_seqlen = option.xpu_adaptive_seqlen;
|
lite_option.kunlunxin_adaptive_seqlen = option.kunlunxin_adaptive_seqlen;
|
||||||
lite_option.xpu_enable_multi_stream = option.xpu_enable_multi_stream;
|
lite_option.kunlunxin_enable_multi_stream = option.kunlunxin_enable_multi_stream;
|
||||||
|
|
||||||
FDASSERT(option.model_format == ModelFormat::PADDLE,
|
FDASSERT(option.model_format == ModelFormat::PADDLE,
|
||||||
"LiteBackend only support model format of ModelFormat::PADDLE");
|
"LiteBackend only support model format of ModelFormat::PADDLE");
|
||||||
|
@@ -120,9 +120,9 @@ struct FASTDEPLOY_DECL RuntimeOption {
|
|||||||
void UseAscend();
|
void UseAscend();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// \brief Turn on XPU.
|
/// \brief Turn on KunlunXin XPU.
|
||||||
///
|
///
|
||||||
/// \param xpu_id the XPU card to use (default is 0).
|
/// \param kunlunxin_id the KunlunXin XPU card to use (default is 0).
|
||||||
/// \param l3_workspace_size The size of the video memory allocated by the l3
|
/// \param l3_workspace_size The size of the video memory allocated by the l3
|
||||||
/// cache, the maximum is 16M.
|
/// cache, the maximum is 16M.
|
||||||
/// \param locked Whether the allocated L3 cache can be locked. If false,
|
/// \param locked Whether the allocated L3 cache can be locked. If false,
|
||||||
@@ -139,9 +139,10 @@ struct FASTDEPLOY_DECL RuntimeOption {
|
|||||||
/// file will be used and autotune will not be performed again.
|
/// file will be used and autotune will not be performed again.
|
||||||
/// \param precision Calculation accuracy of multi_encoder
|
/// \param precision Calculation accuracy of multi_encoder
|
||||||
/// \param adaptive_seqlen Is the input of multi_encoder variable length
|
/// \param adaptive_seqlen Is the input of multi_encoder variable length
|
||||||
/// \param enable_multi_stream Whether to enable the multi stream of xpu.
|
/// \param enable_multi_stream Whether to enable the multi stream of
|
||||||
|
/// KunlunXin XPU.
|
||||||
///
|
///
|
||||||
void UseXpu(int xpu_id = 0,
|
void UseKunlunXin(int kunlunxin_id = 0,
|
||||||
int l3_workspace_size = 0xfffc00,
|
int l3_workspace_size = 0xfffc00,
|
||||||
bool locked = false,
|
bool locked = false,
|
||||||
bool autotune = true,
|
bool autotune = true,
|
||||||
@@ -449,7 +450,7 @@ struct FASTDEPLOY_DECL RuntimeOption {
|
|||||||
|
|
||||||
bool enable_timvx = false;
|
bool enable_timvx = false;
|
||||||
bool enable_ascend = false;
|
bool enable_ascend = false;
|
||||||
bool enable_xpu = false;
|
bool enable_kunlunxin = false;
|
||||||
|
|
||||||
// ======Only for Trt Backend=======
|
// ======Only for Trt Backend=======
|
||||||
std::map<std::string, std::vector<int32_t>> trt_max_shape;
|
std::map<std::string, std::vector<int32_t>> trt_max_shape;
|
||||||
@@ -482,14 +483,14 @@ struct FASTDEPLOY_DECL RuntimeOption {
|
|||||||
fastdeploy::rknpu2::CoreMask rknpu2_core_mask_ =
|
fastdeploy::rknpu2::CoreMask rknpu2_core_mask_ =
|
||||||
fastdeploy::rknpu2::CoreMask::RKNN_NPU_CORE_AUTO;
|
fastdeploy::rknpu2::CoreMask::RKNN_NPU_CORE_AUTO;
|
||||||
|
|
||||||
// ======Only for XPU Backend=======
|
// ======Only for KunlunXin XPU Backend=======
|
||||||
int xpu_l3_workspace_size = 0xfffc00;
|
int kunlunxin_l3_workspace_size = 0xfffc00;
|
||||||
bool xpu_locked = false;
|
bool kunlunxin_locked = false;
|
||||||
bool xpu_autotune = true;
|
bool kunlunxin_autotune = true;
|
||||||
std::string xpu_autotune_file = "";
|
std::string kunlunxin_autotune_file = "";
|
||||||
std::string xpu_precision = "int16";
|
std::string kunlunxin_precision = "int16";
|
||||||
bool xpu_adaptive_seqlen = false;
|
bool kunlunxin_adaptive_seqlen = false;
|
||||||
bool xpu_enable_multi_stream = false;
|
bool kunlunxin_enable_multi_stream = false;
|
||||||
|
|
||||||
std::string model_file = ""; // Path of model file
|
std::string model_file = ""; // Path of model file
|
||||||
std::string params_file = ""; // Path of parameters file, can be empty
|
std::string params_file = ""; // Path of parameters file, can be empty
|
||||||
|
@@ -30,7 +30,7 @@ PaddleClasModel::PaddleClasModel(const std::string& model_file,
|
|||||||
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};
|
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};
|
||||||
valid_timvx_backends = {Backend::LITE};
|
valid_timvx_backends = {Backend::LITE};
|
||||||
valid_ascend_backends = {Backend::LITE};
|
valid_ascend_backends = {Backend::LITE};
|
||||||
valid_xpu_backends = {Backend::LITE};
|
valid_kunlunxin_backends = {Backend::LITE};
|
||||||
valid_ipu_backends = {Backend::PDINFER};
|
valid_ipu_backends = {Backend::PDINFER};
|
||||||
} else if (model_format == ModelFormat::ONNX) {
|
} else if (model_format == ModelFormat::ONNX) {
|
||||||
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO};
|
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO};
|
||||||
|
@@ -27,7 +27,7 @@ YOLOv5::YOLOv5(const std::string& model_file, const std::string& params_file,
|
|||||||
} else {
|
} else {
|
||||||
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
||||||
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
||||||
valid_xpu_backends = {Backend::LITE};
|
valid_kunlunxin_backends = {Backend::LITE};
|
||||||
valid_timvx_backends = {Backend::LITE};
|
valid_timvx_backends = {Backend::LITE};
|
||||||
valid_ascend_backends = {Backend::LITE};
|
valid_ascend_backends = {Backend::LITE};
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ YOLOv6::YOLOv6(const std::string& model_file, const std::string& params_file,
|
|||||||
} else {
|
} else {
|
||||||
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
||||||
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
||||||
valid_xpu_backends = {Backend::LITE};
|
valid_kunlunxin_backends = {Backend::LITE};
|
||||||
valid_ascend_backends = {Backend::LITE};
|
valid_ascend_backends = {Backend::LITE};
|
||||||
}
|
}
|
||||||
runtime_option = custom_option;
|
runtime_option = custom_option;
|
||||||
|
@@ -27,7 +27,7 @@ YOLOv7::YOLOv7(const std::string& model_file, const std::string& params_file,
|
|||||||
} else {
|
} else {
|
||||||
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
|
||||||
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
valid_gpu_backends = {Backend::PDINFER, Backend::ORT, Backend::TRT};
|
||||||
valid_xpu_backends = {Backend::LITE};
|
valid_kunlunxin_backends = {Backend::LITE};
|
||||||
valid_ascend_backends = {Backend::LITE};
|
valid_ascend_backends = {Backend::LITE};
|
||||||
}
|
}
|
||||||
runtime_option = custom_option;
|
runtime_option = custom_option;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user