mirror of
https://github.com/pykeio/ort
synced 2026-04-26 00:44:56 +02:00
1.3 KiB
1.3 KiB
WASM-Emscripten Example
Example how to use ort to run onnxruntime in the Web with multi-threaded execution. Here inferencing the YoloV8 model.
Prepare environment
- Requires a recent Rust installation via
rustup,git,cmakeandbuild-essentials,libssl-dev, andpkg-configunder Ubuntu orxcode-selectunder macOS. - Install the Rust nightly toolchain with
rustup install nightly. - Add Emscripten as Rust target with
rustup target add wasm32-unknown-emscripten --toolchain nightly. - Clone Emscripten SDK via
git clone https://github.com/emscripten-core/emsdk.git --depth 1. - Install Emscripten SDK 4.0.4 locally to match version used in ONNX runtime via
./emsdk/emsdk install 4.0.4. - Prepare local Emscripten SDK via
./emsdk/emsdk activate 4.0.4.
Environment tested on Ubuntu 24.04 and macOS 14.7.1.
Build example
- Set local Emscripten SDK in current session via
source ./emsdk/emsdk_env.sh. - Build the example via
cargo buildfor a debug build orcargo build --releasefor a release build.
Serve example
- Serve a debug build via
python3 serve.pyor a release build viapython3 serve.py --release. Pre-installed Python 3 should be sufficient.