Safe MMDeploy Rust wrapper.
To make sure the building of this repo in success, you should install some pre-packages.
The following guidance is tested on Ubuntu OS on x86 device.
Step 1. Install Clang required by Bindgen
.
bash
apt install llvm-dev libclang-dev clang
Step 2. Download and install pre-built mmdeploy package. In this guidance, we choose a MMdepoloy prebuilt package target on ONNXRUNTIME-linux-x86.
bash
wget https://github.com/open-mmlab/mmdeploy/releases/download/v0.8.0/mmdeploy-0.8.0-linux-x86_64-onnxruntime1.8.1.tar.gz
tar -zxvf mmdeploy-0.8.0-linux-x86_64-onnxruntime1.8.1.tar.gz
cd mmdeploy-0.8.0-linux-x86_64-onnxruntime1.8.1.tar.gz
export $MMDEPLOY_DIR=$(pwd)
Step 3. Install OpenCV required by examples.
bash
apt install libopencv-dev
Please read the previous section to make sure the required packages have been installed before using this crate.
Update your Cargo.toml
toml
mmdeploy = "0.7.0"
Good news: Now, you can use Rust language to build your fantastic applications powered by MMDeploy! Take a look by running some examples!
Deploy image classification models converted by MMDeploy.
The example deploys a ResNet model converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert an appropriate model in ../mmdeploy_model/resnet
. An optional operation required to fetch MMClassification codebase into ../mmclassification/
. In this example, we use demo-image from it.
bash
cargo run --example classifier cpu ../mmdeploy_model/resnet ../mmclassification/demo/dog.jpg
Deploy object detection models converted by MMDeploy.
The example deploys a FasterRCNN model converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert an appropriate model in ../mmdeploy_model/faster-rcnn-ort
. An optional operation required to fetch MMDetection codebase into ../mmdetection/
. In this example, we use demo-image from it.
bash
cargo run --example detector cpu ../mmdeploy_model/faster-rcnn-ort ../mmdetection/demo/demo.jpg
A rendered result we can take a look located in the current directory and is named output_detection.png
.
Deploy object segmentation models converted by MMDeploy.
The example deploys a DeepLabv3 model converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert an appropriate model in ../mmdeploy_model/deeplabv3
. An optional operation required to fetch MMSegmentation codebase into ../mmsegmentation/
. In this example, we use demo-image from it.
bash
cargo run --example segmentor cpu ../mmdeploy_model/deeplabv3 ../mmsegmentation/demo/demo.png
A rendered result we can take a look located in the current directory and is named output_segmentation.png
.
Deploy pose detection models converted by MMDeploy.
The example deploys an HRNet model converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert an appropriate model in ../mmdeploy_model/hrnet
. An optional operation required to fetch MMPose codebase into ../mmpose/
. In this example, we use demo-image from it.
bash
cargo run --example pose_detector cpu ../mmdeploy_model/hrnet ../mmdeploy/demo/resources/human-pose.jpg
A rendered result we can take a look located in the current directory and is named output_pose.png
.
Deploy rotated detection models converted by MMDeploy.
The example deploys a RetinaNet model converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert an appropriate model in ../mmdeploy_model/retinanet
. An optional operation required to fetch MMRotate codebase into ../mmrotate/
. In this example, we use demo-image from it.
bash
cargo run --example rotated_detector cpu ../mmdeploy_model/retinanet ../mmrotate/demo/demo.jpg
A rendered result we can take a look located in the current directory and is named output_rotated_detection.png
.
Deploy pose detection models converted by MMDeploy.
The example deploys a DBNet model for detection and a CRNN model for recognition both converted by ONNXRUNTIME target on CPU device.
Before deploying, please follow the guidance from MMDeploy documentation to install it and convert appropriate models in ../mmdeploy_model/dbnet
and ../mmdeploy_model/crnn
. Optional operations required to fetch MMOCR codebase into ../mmocr/
. In this example, we use demo-image from it.
bash
cargo run --example ocr cpu ../mmdeploy_model/dbnet ../mmdeploy_model/crnn ../mmocr/demo/demo_text_det.jpg
A rendered result we can take a look located in the current directory and is named output_ocr.png
.