
* [PaddlePaddle Hackathon4 No.186] Add PaddleDetection Models Deployment Go Examples Signed-off-by: wanziyu <ziyuwan@zju.edu.cn> * Fix YOLOv8 Deployment Go Example Signed-off-by: wanziyu <ziyuwan@zju.edu.cn> * [Hackathon4 No.184] Add PaddleDetection Models Deployment Rust Examples Signed-off-by: wanziyu <ziyuwan@zju.edu.cn> * Add main and cargo files in examples Signed-off-by: wanziyu <ziyuwan@zju.edu.cn> --------- Signed-off-by: wanziyu <ziyuwan@zju.edu.cn> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
English | 简体中文
PaddleDetection Rust Deployment Example
This directory provides examples that main.rs
andbuild.rs
use bindgen
to call FastDeploy C API and fast finish the deployment of PaddleDetection model YOLOv8 on CPU/GPU.
Before deployment, three steps require confirmation
-
- Software and hardware should meet the requirements. Please refer to FastDeploy Environment Requirements
-
- Download the precompiled deployment library and samples code according to your development environment. Refer to FastDeploy Precompiled Library
-
- Download Rustup and install Rust
Taking inference on Linux as an example, the compilation test can be completed by executing the following command in this directory. FastDeploy version 1.0.4 above (x.x.x>1.0.4) or develop version (x.x.x=0.0.0) is required to support this model.
Use Rust and bindgen to deploy YOLOv8 model
Download the FastDeploy precompiled library. Users can choose your appropriate version in the FastDeploy Precompiled Library
mentioned above.
wget https://fastdeploy.bj.bcebos.com/dev/cpp/fastdeploy-linux-x64-0.0.0.tgz
tar xvf fastdeploy-linux-x64-0.0.0.tgz
Download the YOLOv8 ONNX model file and test images
wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov8s.onnx
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
In build.rs
, configure thecargo:rustc-link-search
to FastDeploy dynamic library path. The FastDeploy dynamic library is located in the /lib
directory. Configure thecargo:rustc-link-lib
to FastDeploy dynamic libraryfastdeploy
and theheaders_dir
to FastDeploy C API directory path.
println!("cargo:rustc-link-search=./fastdeploy-linux-x64-0.0.0/lib");
println!("cargo:rustc-link-lib=fastdeploy");
let headers_dir = PathBuf::from("./fastdeploy-linux-x64-0.0.0/include");
Use the following command to add Fastdeploy library path to the environment variable.
source /Path/to/fastdeploy-linux-x64-0.0.0/fastdeploy_init.sh
Use Cargo
tool to compile the Rust project.
cargo build
After compiling, use the following command to obtain the predicted results.
# CPU inference
cargo run -- --model yolov8s.onnx --image 000000014439.jpg --device 0
# GPU inference
cargo run -- --model yolov8s.onnx --image 000000014439.jpg --device 1
Then visualized inspection result is saved in the local image vis_result_yolov8.jpg
.