This package is a high-level Rust bindings for wasi-nn example of Mobilenet with Tensorflow Lite backend.
This crate depends on the wasi-nn
in the Cargo.toml
:
[dependencies]
wasi-nn = "0.4.0"
Compile the application to WebAssembly:
cd rust && cargo build --target=wasm32-wasi --release
The output WASM file will be at rust/target/wasm32-wasi/release/wasmedge-wasinn-example-tflite-bird-image.wasm
.
To speed up the image processing, we can enable the AOT mode in WasmEdge with:
wasmedge compile rust/target/wasm32-wasi/release/wasmedge-wasinn-example-tflite-bird-image.wasm wasmedge-wasinn-example-tflite-bird-image.wasm
The testing image is located at ./bird.jpg
:
The tflite
model is located at ./lite-model_aiy_vision_classifier_birds_V1_3.tflite
Users should install the WasmEdge with WASI-NN TensorFlow-Lite backend plug-in.
Execute the WASM with the wasmedge
with Tensorflow Lite supporting:
wasmedge --dir .:. wasmedge-wasinn-example-tflite-bird-image.wasm lite-model_aiy_vision_classifier_birds_V1_3.tflite bird.jpg
You will get the output:
Read graph weights, size in bytes: 3561598
Loaded graph into wasi-nn with ID: 0
Created wasi-nn execution context with ID: 0
Read input tensor, size in bytes: 150528
Executed graph inference
1.) [166](198)Aix galericulata
2.) [158](2)Coccothraustes coccothraustes
3.) [34](1)Gallus gallus domesticus
4.) [778](1)Sitta europaea
5.) [819](1)Anas platyrhynchos