Path: blob/main/crates/wasi-nn/examples/classification-example-pytorch/README.md
1692 views
This example project demonstrates using the wasi-nn
API to perform PyTorch based inference. It consists of Rust code that is built using the wasm32-wasip1
target.
To run this example:
Ensure you set appropriate Libtorch environment variables according to tch-rs instructions.
Requires the C++ PyTorch library (libtorch) in version v2.4.0 to be available on your system.
export LIBTORCH=/path/to/libtorch
Build Wasmtime with
wasmtime-wasi-nn/pytorch
feature.Navigate to this example directory
crates/wasi-nn/examples/classification-example-pytorch
.Download
squeezenet1_1.pt
model
Build this example
cargo build --target=wasm32-wasip1
.Run the generated wasm file with wasmtime after mapping the directory containing squeezenet1.1
model.pt
and sample imagekitten.png
Check that result
281
has highest probability, which corresponds totabby cat
.