Safe MMDeploy Rust wrapper.

Overview

Introduction

Safe MMDeploy Rust wrapper.

News

Prerequisites

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 and Rust required by Bindgen.

apt install llvm-dev libclang-dev clang curl wget git-lfs
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

Step 2. Download and install pre-built mmdeploy package and onnxruntime. In this guidance, we choose a MMdepoloy prebuilt package target on ONNXRUNTIME-linux-x86.

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
pushd mmdeploy-0.8.0-linux-x86_64-onnxruntime1.8.1
export MMDEPLOY_DIR=$(pwd)/sdk
export LD_LIBRARY_PATH=$MMDEPLOY_DIR/sdk/lib:$LD_LIBRARY_PATH
popd

wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
tar -zxvf onnxruntime-linux-x64-1.8.1.tgz
cd onnxruntime-linux-x64-1.8.1
export ONNXRUNTIME_DIR=$(pwd)
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH

Step 3. (Optional) Install OpenCV required by examples.

apt install libopencv-dev

Step 4. (Optional) Download converted onnx model by mmdeploy

git clone https://github.com/liu-mengyang/mmdeploy-converted-models --depth=1

Quickstart

Please read the previous section to make sure the required packages have been installed before using this crate.

Update your Cargo.toml

mmdeploy = "0.8.1"

APIs for MM Codebases

Good news: Now, you can use Rust language to build your fantastic applications powered by MMDeploy! Take a look by running some examples!

Models and Testdata

You can

Classifier API

Deploy image classification models converted by MMDeploy.

The example deploys a ResNet model converted by ONNXRUNTIME target on CPU device.

cargo run --example classifier cpu ../mmdeploy-converted-models/resnet ./images/demos/mmcls_demo.jpg

Detector API

Deploy object detection models converted by MMDeploy.

The example deploys a FasterRCNN model converted by ONNXRUNTIME target on CPU device.

cargo run --example detector cpu ../mmdeploy-converted-models/faster-rcnn-ort ./images/demos/mmdet_demo.jpg

A rendered result we can take a look located in the current directory and is named output_detection.png.

Segmentor API

Deploy object segmentation models converted by MMDeploy.

The example deploys a DeepLabv3 model converted by ONNXRUNTIME target on CPU device.

cargo run --example segmentor cpu ../mmdeploy-converted-models/deeplabv3 ./images/demos/mmseg_demo.png

A rendered result we can take a look located in the current directory and is named output_segmentation.png.

Pose detector API

Deploy pose detection models converted by MMDeploy.

The example deploys an HRNet model converted by ONNXRUNTIME target on CPU device.

cargo run --example pose_detector cpu ../mmdeploy-converted-models/hrnet ./images/demos/mmpose_demo.jpg

A rendered result we can take a look located in the current directory and is named output_pose.png.

Rotated detector API

Deploy rotated detection models converted by MMDeploy.

The example deploys a RetinaNet model converted by ONNXRUNTIME target on CPU device.

cargo run --example rotated_detector cpu ../mmdeploy-converted-models/retinanet ./images/demos/mmrotate_demo.jpg

A rendered result we can take a look located in the current directory and is named output_rotated_detection.png.

OCR API

Deploy text detection and text recognition 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.

cargo run --example ocr cpu ../mmdeploy-converted-models/dbnet ../mmdeploy-converted-models/crnn ./images/demos/mmocr_demo.jpg

A rendered result we can take a look located in the current directory and is named output_ocr.png.

Restorer API

Deploy restorer models converted by MMDeploy.

The example deploys an EDSR model for restoration converted by ONNXRUNTIME target on CPU device.

cargo run --example restorer cpu ../mmdeploy-converted-models/edsr ./images/demos/mmediting_demo.png

A rendered result we can take a look located in the current directory and is named output_restorer.png.

TOSupport List

  • Classifier
  • Detector
  • Segmentor
  • Pose Detector
  • Rotated Detector
  • Text Detector
  • Text Recognizer
  • Restorer

TODO List

  • PR for contributing a rust-mmdeploy-CI into MMDeploy
  • Test with TensorRT prebuilt package
  • Tutorial of rust-mmdeploy
  • Documentation of rust-mmdeploy and rust-mmdeploy-sys
You might also like...
Safe, efficient, and ergonomic bindings to Wolfram LibraryLink and the Wolfram Language

wolfram-library-link Bindings to the Wolfram LibraryLink interface, making it possible to call Rust code from the Wolfram Language. This library is us

A type-safe, high speed programming language for scalable systems

A type-safe, high speed programming language for scalable systems! (featuring a cheesy logo!) note: the compiler is unfinished and probably buggy. if

Simple, safe way to store and distribute tensors

safetensors Safetensors This repository implements a new simple format for storing tensors safely (as opposed to pickle) and that is still fast (zero-

Thread-safe clone-on-write container for fast concurrent writing and reading.

sync_cow Thread-safe clone-on-write container for fast concurrent writing and reading. SyncCow is a container for concurrent writing and reading of da

Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.
Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.

Linked Atomic Random Insert Vector Lariv is a thread-safe, self-memory-managed vector with no guaranteed sequential insert. It internally uses a linke

A asynchronous implementation of the invidious innertube aka youtubei API wrapper

A asynchronous implementation of the invidious innertube aka youtubei API wrapper. Using tokio,reqwest, serde and serde_json

A rocksdb.rs wrapper bringing stack and queue functionalities

RocksDB_sq (Stack & Queue) A Rust crate that adds stack and queue functionality to RocksDB. This crate provide a wrapper around a RocksDB database and

A shit dAPI wrapper.

Shit dAPI wrapper A Blazingly Fast (🚀🚀🚀) discord API wrapper so shit it makes your bot say shit uncontrollably. usage: clone this repo and change t

Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Owner
Mengyang Liu
CS Master student, rustacean, machine learning system newbie.
Mengyang Liu
Safe, comp time generated queries in rust

query_builder For each struct field following methods will be generated. All fields where_FIELDNAME_eq Numeric fields where_FIELDNAME_le where_FIELDNA

Amirreza Askarpour 2 Oct 31, 2021
Safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework.

Introduction The dynamorio-rs crate provides safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework, essentially allowing you to

S.J.R. van Schaik 17 Nov 21, 2022
Build database expression type checker and vectorized runtime executor in type-safe Rust

Typed Type Exercise in Rust Build database expression type checker and vectorized runtime executor in type-safe Rust. This project is highly inspired

Andy Lok 89 Dec 27, 2022
Safe, idiomatic bindings to cFE and OSAL APIs for Rust

n2o4 The n2o4 crate provides safe, idiomatic Rust bindings to the APIs of cFE and OSAL, the libraries of the Core Flight System (cFS). IMPORTANT NOTE

null 3 Aug 29, 2022
Blazing fast, memory safe & modern Linux package manager written in Rust.

paket Blazing fast, memory safe & modern Linux package manager written in Rust. Roadmap Version: 0.1 Paket.toml file parsing. (#1, #2) CLI handling (p

null 4 Oct 19, 2023
Rust wrapper for `os-release`

os-release-rs Rust wrapper for /etc/os-release file. Installation Add this to your Cargo.toml: [dependencies] os-release-rs = "0.1.0" Usage use os_rel

0xMRTT 2 Nov 11, 2022
A wrapper around Rust futures that stores the future in space provided by the caller.

StackFuture This crate defines a StackFuture wrapper around futures that stores the wrapped future in space provided by the caller. This can be used t

Microsoft 278 Dec 29, 2022
Rust wrapper for the LeapC Ultraleap (Leap Motion) hand tracking device API.

LeapRS LeapRS is a safe wrapper for LeapC, the Leap Motion C API. It uses the generated binding provided by leap-sys. This is an API for accessing Lea

Pierre Lulé 4 Oct 10, 2022
This is for aquestalk1 rust wrapper.

aquestalk-rs This is for aquestalk1 rust wrapper. 読み上げに使用する際 aquestalkを使ってDiscord読み上げbotなどを作成する場合aquestalkに問い合わせして、サーバー用ライセンスの購入が必須です。 Installation [d

KuronekoServer 2 Nov 16, 2022
c-library wrapper around the rust pdb crate

pdbcrust: pdbcrust is a c-library wrapper around the rust pdb crate. The API only exports a minimum subset of the pdb crate functionality. The project

Ulf Frisk 7 Feb 23, 2023